Skip to content

Commit bdd026d

Browse files
committed
fix the topic filtering
1 parent 8d5d636 commit bdd026d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

backend/app/services/topic_service.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,20 @@ def process_topics(self, search_term: str):
6060
FROM repos r
6161
JOIN repo_topics t ON r.nameWithOwner = t.repo
6262
WHERE LOWER(t.topics) LIKE '%' || ? || '%'
63+
),
64+
split_topics AS (
65+
SELECT
66+
fr.nameWithOwner,
67+
unnest(string_split(t.topics, '|')) as topic
68+
FROM filtered_repos fr
69+
JOIN repo_topics t ON fr.nameWithOwner = t.repo
6370
)
6471
SELECT
65-
unnest(string_split(t.topics, '|')) as topic,
72+
topic,
6673
COUNT(*) as count
67-
FROM filtered_repos fr
68-
JOIN repo_topics t ON fr.nameWithOwner = t.repo
69-
WHERE LOWER(unnest(string_split(t.topics, '|'))) != ?
70-
GROUP BY unnest(string_split(t.topics, '|'))
74+
FROM split_topics
75+
WHERE LOWER(topic) != ?
76+
GROUP BY topic
7177
HAVING COUNT(*) > 2
7278
ORDER BY count DESC
7379
"""

0 commit comments

Comments
 (0)