Skip to content

feat: add GitHub download statistics for app developers#1796

Draft
miaulalala wants to merge 2 commits into
masterfrom
feature/github-download-stats
Draft

feat: add GitHub download statistics for app developers#1796
miaulalala wants to merge 2 commits into
masterfrom
feature/github-download-stats

Conversation

@miaulalala

Copy link
Copy Markdown
Contributor

Summary

  • Extends GitHubClient with get_releases() to fetch per-asset download counts from the GitHub API (and fixes a long-standing inverted auth header bug)
  • Adds get_download_counts() which groups releases by (owner, repo) to minimise API calls; non-GitHub URLs return null
  • New API endpoint GET /api/v1/apps/{id}/downloads — owner/co-maintainer only, returns JSON list with version, is_nightly, download, download_count per release
  • New web page /apps/{id}/downloads with a table of the same data, linked from the app detail sidebar under a "Developer" section (visible only to owners/co-maintainers)

Context

88.6% of the ~15k releases in the app store are hosted on GitHub using the standard releases/download URL pattern, so the GitHub API covers the vast majority of apps without any changes to how developers register releases. Releases on other hosts (GitLab, self-hosted, etc.) show null.

A GITHUB_API_TOKEN should be set in production settings to avoid the 60 req/hr unauthenticated rate limit.

Test plan

  • 18 new tests pass: python manage.py test nextcloudappstore.core.tests.test_github nextcloudappstore.api.v1.tests.test_app_download_stats
  • Log in as app owner → app detail page shows "Developer / Download statistics" button
  • Non-owners do not see the button and get 403 on the page/API
  • Download stats page renders counts for GitHub-hosted releases; non-GitHub URLs show "— not available"

🤖 Generated with Claude Code

miaulalala and others added 2 commits June 17, 2026 21:46
- Parse GitHub release asset URLs stored in AppRelease.download
- Extend GitHubClient with get_releases() to fetch per-asset download
  counts from the GitHub API; also fix inverted auth header bug
- Add get_download_counts() to aggregate counts across releases,
  grouping by repo to minimise API calls; non-GitHub URLs return null
- New API endpoint GET /api/v1/apps/{id}/downloads (owner/co-maintainer
  only) returns JSON with version, channel, download_count per release
- New web page /apps/{id}/downloads shows the same data in a table,
  linked from the app detail sidebar under a Developer section
- 18 new tests covering URL parsing, count fetching, deduplication,
  and all HTTP permission scenarios

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Anna Larch <anna@nextcloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant