diff --git a/server/.sqlx/query-a9146592da9133424ee9c022b7ff390ba82a1c72f3525f4ef85e61f4ab9f3955.json b/server/.sqlx/query-7af477a7393355e1a65821ada0238173118eb50086c6aa924b40471954d54c3c.json similarity index 92% rename from server/.sqlx/query-a9146592da9133424ee9c022b7ff390ba82a1c72f3525f4ef85e61f4ab9f3955.json rename to server/.sqlx/query-7af477a7393355e1a65821ada0238173118eb50086c6aa924b40471954d54c3c.json index e0f4bd7..4b34587 100644 --- a/server/.sqlx/query-a9146592da9133424ee9c022b7ff390ba82a1c72f3525f4ef85e61f4ab9f3955.json +++ b/server/.sqlx/query-7af477a7393355e1a65821ada0238173118eb50086c6aa924b40471954d54c3c.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "WITH top_contributors AS (\n SELECT\n pr.repo_id,\n u.login AS contributor_login,\n u.full_name AS contributor_full_name,\n ROW_NUMBER() OVER (\n PARTITION BY pr.repo_id\n ORDER BY\n SUM(pr.rating) DESC\n ) AS rank\n FROM\n pull_requests pr\n JOIN users u ON pr.author_id = u.id\n WHERE\n pr.included_at >= $3\n GROUP BY\n pr.repo_id,\n u.id\n)\nSELECT\n o.login AS organization,\n o.full_name AS organization_full_name,\n r.name AS name,\n COALESCE(COUNT(pr.id), 0) AS total_prs,\n COALESCE(SUM(pr.score), 0) AS total_score,\n COALESCE(SUM(pr.rating), 0) AS total_rating,\n MAX(tc.contributor_full_name) AS contributor_full_name,\n MAX(tc.contributor_login) AS contributor_login,\n r.primary_language,\n r.open_issues,\n r.stars,\n r.forks\nFROM\n repos r\n JOIN organizations o ON r.organization_id = o.id\n LEFT JOIN pull_requests pr ON pr.repo_id = r.id\n LEFT JOIN top_contributors tc ON tc.repo_id = r.id\n AND tc.rank = 1\nWHERE\n r.paused = false\n AND r.banned = false\nGROUP BY\n o.login,\n o.full_name,\n r.name,\n r.primary_language,\n r.open_issues,\n r.stars,\n r.forks\nORDER BY\n total_prs DESC,\n open_issues DESC,\n organization ASC,\n name ASC\nLIMIT\n $1 OFFSET $2;\n", + "query": "WITH top_contributors AS (\n SELECT\n pr.repo_id,\n u.login AS contributor_login,\n u.full_name AS contributor_full_name,\n ROW_NUMBER() OVER (\n PARTITION BY pr.repo_id\n ORDER BY\n SUM(pr.rating) DESC\n ) AS rank\n FROM\n pull_requests pr\n JOIN users u ON pr.author_id = u.id\n WHERE\n pr.included_at >= $3\n GROUP BY\n pr.repo_id,\n u.id\n)\nSELECT\n o.login AS organization,\n o.full_name AS organization_full_name,\n r.name AS name,\n COALESCE(COUNT(pr.id), 0) AS total_prs,\n COALESCE(SUM(pr.score), 0) AS total_score,\n COALESCE(SUM(pr.rating), 0) AS total_rating,\n MAX(tc.contributor_full_name) AS contributor_full_name,\n MAX(tc.contributor_login) AS contributor_login,\n r.primary_language,\n r.open_issues,\n r.stars,\n r.forks\nFROM\n repos r\n JOIN organizations o ON r.organization_id = o.id\n LEFT JOIN pull_requests pr ON pr.repo_id = r.id\n LEFT JOIN top_contributors tc ON tc.repo_id = r.id\n AND tc.rank = 1\nWHERE\n r.paused = false\n AND r.banned = false\nGROUP BY\n o.login,\n o.full_name,\n r.name,\n r.primary_language,\n r.open_issues,\n r.stars,\n r.forks\nHAVING\n COUNT(pr.id) > 0\nORDER BY\n total_prs DESC,\n open_issues DESC,\n organization ASC,\n name ASC\nLIMIT\n $1 OFFSET $2;\n", "describe": { "columns": [ { @@ -86,5 +86,5 @@ true ] }, - "hash": "a9146592da9133424ee9c022b7ff390ba82a1c72f3525f4ef85e61f4ab9f3955" + "hash": "7af477a7393355e1a65821ada0238173118eb50086c6aa924b40471954d54c3c" } diff --git a/server/sql/get_repo_leaderboard.sql b/server/sql/get_repo_leaderboard.sql index 31bec16..7a15006 100644 --- a/server/sql/get_repo_leaderboard.sql +++ b/server/sql/get_repo_leaderboard.sql @@ -47,6 +47,8 @@ GROUP BY r.open_issues, r.stars, r.forks +HAVING + COUNT(pr.id) > 0 ORDER BY total_prs DESC, open_issues DESC,