Skip to content

feat: collection contributors routes - #2347

Open
epipav wants to merge 2 commits into
mainfrom
feat/IN-1411
Open

epipav wants to merge 2 commits into
mainfrom
feat/IN-1411

Conversation

@epipav

@epipav epipav commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Serves the 10 contributors widgets for a collection under /v1-alpha/collections/{slug}/contributors/* (IN-1411, epic IN-1146). Each one reuses its project route handler and passes collectionSlug to the pipe in place of project.

  • widgetRoutes in src/lib/widget-scope.ts registers one handler under both /projects/{slug}/<path> and /collections/{slug}/<path>. The development and popularity groups adopt it next.
  • The collection variant resolves the slug through the shared collections query first, so an unknown or private collection answers 404 before any Tinybird call. The Tinybird client resolves the collection's bucket from the slug, so the project bucket lookup is skipped.
  • repos is not offered for a collection, matching what the Nuxt app sends.
  • Collection variants are tagged Collections. Their descriptions are rewritten from the project text so they read correctly for a collection, and they gain a sentence about the 404.
  • The project routes' behaviour and OpenAPI output are unchanged.

Notes

  • Pipe support for collectionSlug is taken from the Nuxt app, which already calls the same pipes for these widgets in collection scope. All 10 contributors pipes qualify, so none is left out.
  • activityFilterParams in the Tinybird client now takes the scope target, so collection calls skip the project-only params.

Tests

  • tests/project-routes.test.ts: a collection-scope variant of the shared route suite covering 404, collectionSlug forwarding, the cache header, 503 mapping, 400s and the OpenAPI listing.
  • tests/widget-scope.test.ts: description rewriting and schema copying.
  • tests/collections-db.test.ts: collectionExists.

Signed-off-by: anilb <epipav@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:17
@cursor

cursor Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces a new public API surface and collection visibility/404 semantics before upstream calls; logic is shared with project routes so regressions could affect both scopes.

Overview
Adds collection-scoped mirrors of all ten v1-alpha contributors widgets at /v1-alpha/collections/{slug}/contributors/*, reusing the same handlers as the project routes.

A new widgetRoutes helper registers each widget twice: project scope still resolves a Tinybird bucket via withBucket and passes project + bucketId; collection scope checks collectionExists (unknown/private → 404 before Tinybird), strips repos from query/OpenAPI, and forwards collectionSlug through activityFilterParams / pipe queries (bucket via the client’s collection lookup). OpenAPI for collections is tagged Collections, with descriptions rewritten from project copy.

Contributor route files are refactored from inline scope.get to this shared pattern; project behavior and schemas are intended to stay unchanged. Tests add collection parity in project-routes.test.ts, plus widget-scope and collectionExists coverage.

Reviewed by Cursor Bugbot for commit c331d9f. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The discovery test does not verify that every contributor route receives a collection variant.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds collection-scoped variants of the ten contributor widgets while retaining shared project handlers.

Changes:

  • Introduces shared project/collection route registration and schema rewriting.
  • Adds collection validation and Tinybird collection targeting.
  • Expands route, database, and schema tests.
File Description
api/​src/​lib/​widget-scope.ts Adds dual-scope route helper.
api/​src/​lib/​collections-db.ts Adds public collection existence lookup.
api/​src/​clients/​tinybird.ts Accepts project or collection pipe targets.
api/​src/​versions/​v1-alpha/​contributors/​active-contributors.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​active-organizations.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​contributor-dependency.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​contributor-geographical-distribution.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​contributor-leaderboard.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​contributor-retention.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​organization-dependency.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​organization-geographical-distribution.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​organization-leaderboard.ts Adds collection scope.
api/​src/​versions/​v1-alpha/​contributors/​organization-retention.ts Adds collection scope.
api/​tests/​widget-scope.test.ts Tests schema and text rewriting.
api/​tests/​project-routes.test.ts Tests collection route behavior.
api/​tests/​helpers/​tinybird.ts Adds collection-aware Tinybird stubs.
api/​tests/​collections-db.test.ts Tests collection existence lookup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread api/tests/project-routes.test.ts
Signed-off-by: anilb <epipav@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The behavior is comprehensively covered, with only two non-blocking narration-comment convention findings.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (2)

In code that hasn't changed since last review

Low severity Remove redundant narration comment

api/​src/​lib/​widget-scope.ts:12

This comment only restates what widgetRoutes does. CLAUDE.md:178-180 requires comments to explain a constraint or tradeoff and to avoid narration, so please remove it.

Low severity Remove collection-route narration comment

api/​tests/​project-routes.test.ts:427

This comment narrates the collection-route setup immediately below it without explaining a constraint. CLAUDE.md:178-180 explicitly asks contributors to skip narration comments, so please remove it.

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.

2 participants