Created
July 29, 2023 17:05
-
-
Save wenqiglantz/ab2a7427bd55319eee837bc0ddfde065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Pull the repos with the most stars in the past year | |
*/ | |
WITH latest_repo_name AS ( | |
SELECT repo_name, | |
repo_id | |
FROM cybersyn.github_repos | |
QUALIFY ROW_NUMBER() OVER (PARTITION BY repo_id ORDER BY first_seen DESC) = 1 | |
) | |
SELECT repo.repo_name, | |
repo.repo_id, | |
SUM(stars.count) AS sum_stars | |
FROM cybersyn.github_stars AS stars | |
JOIN latest_repo_name AS repo | |
ON (repo.repo_id = stars.repo_id) | |
WHERE stars.date >= DATEADD('day', -365, CURRENT_DATE) | |
GROUP BY repo.repo_name, repo.repo_id | |
ORDER BY sum_stars DESC NULLS LAST | |
LIMIT 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment