Skip to content

Commit

Permalink
feat: allow to search by feature/project ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Zwiterrion authored Dec 6, 2024
1 parent a2e166a commit 0b455c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/fr/maif/izanami/datastores/SearchDatastore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SearchDatastore(val env: Env) extends Datastore {
s"""
scored_projects AS (
SELECT DISTINCT
p.id as id,
p.name,
p.description,
izanami.SIMILARITY(p.name, $$1) AS name_score,
Expand All @@ -43,14 +44,15 @@ class SearchDatastore(val env: Env) extends Datastore {
unionQueries :+= s"""
SELECT row_to_json(p.*) as json, GREATEST(p.name_score, p.description_score) AS match_score, 'project' as _type, $$3 as tenant
FROM scored_projects p
WHERE p.name_score > $similarityThresholdParam OR p.description_score > $similarityThresholdParam"""
WHERE p.name_score > $similarityThresholdParam OR p.description_score > $similarityThresholdParam OR p.id::text = '$query'"""
}

if (filter.isEmpty || filter.contains(Some(SearchEntityObject.Feature))) {
scoredQueries :+=
s"""
scored_features AS (
SELECT DISTINCT
f.id as id,
f.project,
f.name,
f.description,
Expand All @@ -63,7 +65,7 @@ class SearchDatastore(val env: Env) extends Datastore {
unionQueries :+= s"""
SELECT row_to_json(f.*) as json, GREATEST(f.name_score, f.description_score) AS match_score, 'feature' as _type, $$3 as tenant
FROM scored_features f
WHERE f.name_score > $similarityThresholdParam OR f.description_score > $similarityThresholdParam"""
WHERE f.name_score > $similarityThresholdParam OR f.description_score > $similarityThresholdParam OR f.id::text = '$query'"""

}

Expand Down

0 comments on commit 0b455c5

Please sign in to comment.