Skip to content

stats: self-host stargazers chart (fix broken starchart.cc embed)#59

Merged
ErikBjare merged 1 commit into
masterfrom
fix/self-hosted-star-chart
Jul 11, 2026
Merged

stats: self-host stargazers chart (fix broken starchart.cc embed)#59
ErikBjare merged 1 commit into
masterfrom
fix/self-hosted-star-chart

Conversation

@ErikBjare

Copy link
Copy Markdown
Member

Problem

The Stargazers chart on /stats/ is broken: it embeds starchart.cc/ActivityWatch/activitywatch.svg, and GitHub now restricts the stargazers API to a repo's admins/collaborators — third-party services like starchart.cc / star-history.com can't read it anymore without a per-user token.

Fix

We already collect star counts in ActivityWatch/statsdata/stats.csv, every 6h, with complete history from 0 stars (2016) to ~18k today (daily granularity 2017–2020, 6-hourly since). So render the chart ourselves via analyze_stats.py --column stars, exactly like the downloads/Chrome/Firefox/Android images. No external dependency, no token needed.

  • Makefile: add a stars.png render step.
  • stats.pug: swap the starchart.cc <img> for /img/stats/stars.png, linking to the GitHub stargazers page.

Rendered output is a clean cumulative curve identical in shape to what starchart.cc showed.

On backfilling: not needed — our tracked data already covers the full history from project start. (If we ever wanted to reconstruct/verify, the GitHub stargazers endpoint with Accept: application/vnd.github.star+json returns each stargazer's starred_at and still works for repo admins with a token — but it only counts current stargazers, so it's actually less accurate than our point-in-time tracking.)

…estriction)

GitHub now restricts the stargazers API to a repo's admins/collaborators
(github.blog/changelog/2026-06-30-...), so the third-party starchart.cc
embed on /stats/ no longer renders.

We already track star counts in ActivityWatch/stats (data/stats.csv, every
6h, complete history from 0 in 2016 to ~18k today), so render the chart
ourselves via analyze_stats.py --column stars, matching the other stats
images. Removes the external dependency entirely; links to the GitHub
stargazers page instead of starchart.cc.
@ErikBjare ErikBjare merged commit 4fb90f7 into master Jul 11, 2026
2 checks passed
@ErikBjare ErikBjare deleted the fix/self-hosted-star-chart branch July 11, 2026 23:30
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR replaces the broken hosted stargazer chart with a locally generated stats image.

  • Adds a stars.png render step to the stats image target.
  • Points the /stats/ stargazers image at /img/stats/stars.png.
  • Links the chart to the GitHub stargazers page and updates the caption.

Confidence Score: 4/5

The local chart path works with the existing stats image flow, but the new stargazer chart omits the earliest history.

  • The generated image path matches the existing static image layout.
  • The build target follows the existing chart-rendering pattern.
  • The --since 2017-07-01 filter makes the replacement chart incomplete for the stated full-history use case.

Makefile

Important Files Changed

Filename Overview
Makefile Adds the generated stars chart, but filters out the early stargazer history.
stats.pug Switches the stargazers section from the external SVG to the generated local image.

Reviews (1): Last reviewed commit: "stats: self-host stargazers chart (starc..." | Re-trigger Greptile

Comment thread Makefile
mkdir -p img/stats
mkdir -p stats/out
cd stats && poetry run python analyze_stats.py --since 2017-07-01 --column downloads --per-week --save ../img/stats/downloads.png
cd stats && poetry run python analyze_stats.py --since 2017-07-01 --column stars --title 'GitHub Stargazers' --save ../img/stats/stars.png

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Stargazer History Starts Late

The new local stars chart is generated with --since 2017-07-01, so /stats/ will drop the 2016-to-mid-2017 stargazer history that the replacement is meant to preserve. The page now shows a truncated cumulative curve instead of the full project history from the first stars.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02f4628779

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread stats.pug
div.img-center
a(href="https://starchart.cc/ActivityWatch/activitywatch")
img.width-700(title="Stargazers over time" src="https://starchart.cc/ActivityWatch/activitywatch.svg")
a(href="https://github.com/ActivityWatch/activitywatch/stargazers")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid linking the chart to the restricted stargazers view

The replacement chart no longer depends on starchart, but this new click target is the same GitHub /stargazers UI view affected by the access restriction this change is trying to work around; GitHub's changelog says that repository stargazers views may return empty responses or 403s for non-admin/non-collaborator users. For those public visitors, clicking the chart still lands on a broken/restricted page, so link to the repository or the stats data instead.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant