@@ -72,28 +72,44 @@ def generate_gexf_nodes_for_topics(self, topics):
7272 # print(f"Could not get schema: {e}")
7373
7474 query = f"""
75- WITH repo_topics_agg AS (
76- SELECT r.nameWithOwner,
77- GROUP_CONCAT(t.topic, '|') as topics
75+ WITH matching_repos AS (
76+ SELECT DISTINCT r.nameWithOwner
7877 FROM repos r
7978 JOIN repo_topics t ON r.nameWithOwner = t.repo
8079 WHERE LOWER(t.topic) IN ({ placeholders } )
80+ ),
81+ repo_topics_agg AS (
82+ SELECT
83+ r.nameWithOwner,
84+ GROUP_CONCAT(t.topic, '|') AS topics
85+ FROM repos r
86+ JOIN repo_topics t ON r.nameWithOwner = t.repo
87+ JOIN matching_repos mr ON r.nameWithOwner = mr.nameWithOwner
8188 GROUP BY r.nameWithOwner
8289 )
83- SELECT DISTINCT r.nameWithOwner, r.stars, r.forks, r.watchers, r.isArchived,
84- r.languageCount, r.pullRequests, r.issues, r.primaryLanguage, r.createdAt,
85- r.license, rt.topics
90+ SELECT
91+ r.nameWithOwner,
92+ r.stars,
93+ r.forks,
94+ r.watchers,
95+ r.isArchived,
96+ r.languageCount,
97+ r.pullRequests,
98+ r.issues,
99+ r.primaryLanguage,
100+ r.createdAt,
101+ r.license,
102+ rt.topics
86103 FROM repos r
87- JOIN repo_topics t ON r.nameWithOwner = t.repo
88- JOIN repo_topics_agg rt ON r.nameWithOwner = rt.nameWithOwner
89- WHERE LOWER(t.topic) IN ({ placeholders } )
104+ JOIN matching_repos mr ON r.nameWithOwner = mr.nameWithOwner
105+ JOIN repo_topics_agg rt ON r.nameWithOwner = rt.nameWithOwner;
90106 """
91- result = self .con .execute (query , topics_lower + topics_lower ).fetchall ()
107+ result = self .con .execute (query , topics_lower ).fetchall ()
92108
93109 # Debug: Print the first few rows to see what we're getting
94- if result :
95- print (f"First row sample: { result [0 ]} " )
96- print (f"Number of results: { len (result )} " )
110+ # if result:
111+ # print(f"First row sample: {result[0]}")
112+ # print(f"Number of results: {len(result)}")
97113
98114 columns = [
99115 "nameWithOwner" ,
0 commit comments