Closed simonw closed 4 years ago
Paginate through https://api.github.com/repos/simonw/datasette/stargazers
Send Accept: application/vnd.github.v3.star+json
to get the starred_at
dates.
Here's a query I figured out using a window function that shows cumulative stargazers over time:
select
yyyymmdd,
sum(n) over (
order by
yyyymmdd rows unbounded preceding
) as cumulative_count
from
(
select
substr(starred_at, 0, 11) as yyyymmdd,
count(*) as n
from
stars
group by
yyyymmdd
)
I could add that window function query as a view, but only if the detected version of SQLite supports window functions.
I'm not going to do the --sql
bit just yet. I have patterns for working around this for other commands which are working fine:
Alternative pattern:
sqlite-utils releases.db 'select full_name from repos' --csv --no-headers \
| tr -d '\r' \
| xargs github-to-sqlite stargazers stars.db
Needs tests and documentation. I shipped it early to check that the live demo works.
Stars per day (as a label bar chart, so very wide):
Maybe this:
It could accept more than one repos.
Maybe have options similar to
--sql
in twitter-to-sqlite so you can e.g. fetch all stargazers for all of the repos you have fetched into the database already (or all of the repos belonging to owner X)