Repository navigation
feat: add commit activities endpoint under v1-alpha - #2238
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Malformed successful Tinybird responses can bypass error mapping and produce generic 500 responses.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds the /v1-alpha commit-activities metric endpoint backed by Tinybird.
Changes:
- Adds schemas, date conversion, aggregation, and upstream error handling.
- Registers the route and adds comprehensive integration/OpenAPI tests.
| File | Description |
|---|---|
api/src/versions/v1-alpha/development/commit-activities.ts |
Implements the endpoint. |
api/src/versions/v1-alpha/index.ts |
Registers the route plugin. |
api/tests/development-commit-activities.test.ts |
Tests behavior, failures, caching, and OpenAPI. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Malformed Tinybird row fields can still bypass upstream error mapping and cause invalid responses or generic 500 errors.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (1)
gaspergrom
left a comment
There was a problem hiding this comment.
Checked that countType picks between activities_count and activities_cumulative_count without being forwarded to Tinybird, and the concurrency test proves the three pipe calls run in parallel rather than just counting calls. Error mapping and the unknown slug path are well covered too.
f5360d6 to
f0976cc
Compare
f0976cc to
e0adda1
Compare
themarolt
left a comment
There was a problem hiding this comment.
lgtm - one question on the omitted-startDate path, rest reads clean against the Nuxt handler
e0adda1 to
bc805c8
Compare
Signed-off-by: anilb <epipav@gmail.com>
Signed-off-by: anilb <epipav@gmail.com>
bc805c8 to
51bdd99
Compare
Signed-off-by: anilb <epipav@gmail.com>



What
Adds
GET /v1-alpha/projects/{slug}/development/commit-activities, a port of the Nuxt commit-activities widget handler (frontend/server/api/widget/development/commit-activities.get.ts) to the public API.Query:
repos[],startDate,endDate(sharedDateRangeQuery,YYYY-MM-DDUTC days),granularity(required: daily, weekly, monthly, quarterly, yearly) andcountType(newby default, orcumulative).Response:
{ "summary": { "current": 120, "previous": 100, "percentageChange": 20, "changeValue": 20, "periodFrom": "2025-01-01T00:00:00Z", "periodTo": "2025-03-31T00:00:00Z" }, "data": [ { "startDate": "2025-01-01T00:00:00Z", "endDate": "2025-01-31T00:00:00Z", "commits": 40 } ] }Behind it: one
project_bucketslookup, then the same three concurrent Tinybird calls Nuxt makes (activities_counttwice for the current and previous summaries, andactivities_countoractivities_cumulative_countfor the series), with the same fixed parameters (activity_type=authored-commit,onlyContributions=true,includeCodeContributions=true,includeCollaborations=false) and Nuxt'sYYYY-MM-DD 00:00:00date format.Changes vs. the Nuxt handler
type(ignored by the handler) andactivityType(alwaysauthored-commitfrom the UI) are gone;project/collectionSlugare replaced by the path slug.granularityis required. Without it the series pipe falls into summary mode and returns rows without bucket dates.countTypeonly selects the series pipe; it is no longer forwarded to Tinybird.periodFrom/periodToand the bucketstartDate/endDateare ISO-8601 UTC (2025-01-01T00:00:00Z); Nuxt returned Luxon strings and raw pipe dates.percentageChangeis signed (Nuxt usedMath.abs); a drop reads negative likechangeValue.data: [](Nuxt returned 404); the epic's definition of done for metric endpoints.upstream_unavailable; Tinybird's own status never reaches the caller. An inverted date range is a 400invalid_request.Decisions
client.getBucketIdForProject(slug)and passed asbucketIdon the three pipe calls.api/has no bucket cache, so letting the client resolve it per call would mean three lookups per request.getPreviousDatesfills the default (2010-01-01to today) and the previous window, and both are sent on every call, soperiodFrom/periodTomatch what was counted.PeriodSummarykeys and types but describes the counts as commits, so the OpenAPI reference states the unit of every field. Bucket keys staystartDate/endDate/commits, the keys the Nuxt data layer actually emits.tinybirdDay,toUtcDateTime, the described granularity/countType schemas, the summary schema) live in the route file on purpose; the five Development PRs run in parallel and a consolidation chore follows once they merge.Tests
api/tests/development-commit-activities.test.ts: 27 integration tests against the realbuildApp()and Tinybird client, withfetchstubbed per pipe path. They cover the response shape and key stripping, the exact Tinybird calls and their concurrency,countType,granularity, omitted and invalid dates, the unknown slug, every Tinybird failure class,Cache-Control, and the OpenAPI document (tag, parameters, a description on every field,/v1exclusion).pnpm test(189 tests, 14 files),pnpm tsc-check,pnpm lintandpnpm format:checkpass inapi/.Includes the routing-test parser fix from the base branch (62b136b):
version-routing.test.tsnow reads nested route paths, which this is the first route to produce.Based on main, which includes #2241 (IN-1348, directory-based route registration) as dd37a7a. Jira: IN-1332
main