feat(activity): implement API fetcher with pagination and event aggregation #295

Merged
fuzzy merged 1 commit from phase02-fetcher into main 2026-07-07 08:44:04 +00:00
Owner

What

Add API fetcher for the activity view, plus the necessary since parameter support across the forge client interface.

forge.Client changes

  • ListUserActivities now accepts since time.Time — pass zero value for existing behavior
  • Gitea: passes Date field in ListUserActivityFeedsOptions (SDK already supported it)
  • Forgejo: adds &date= query parameter to raw HTTP call
  • CachedClient passes through the since parameter in cache key
  • HomeView caller updated with time.Time{} (no behavior change)

New: fetcher.go

  • FetchActivityEvents() — paginated fetch with PageSize=50, max 500 events, stops when fewer than page-size results returned
  • AggregateActivityByDay() — converts []*ActivityFeed to []DailyActivity, categorizing PR opens/closes and issue opens/closes by UTC-normalized day
  • Unknown op types are silently skipped; dates with zero matched events are excluded from output

References: #190, #187

Testing

  • 5 new aggregation tests: empty, single-day multi-type, multi-day ordering, unknown op types ignored, push-only ignored
  • golangci-lint run ./internal/activity/ ./internal/forge/ — 0 issues
  • go vet ./internal/... — 0 issues
  • go test ./internal/activity/ ./internal/forge/ ./internal/tui/ — all pass
## What Add API fetcher for the activity view, plus the necessary `since` parameter support across the forge client interface. ### forge.Client changes - `ListUserActivities` now accepts `since time.Time` — pass zero value for existing behavior - Gitea: passes `Date` field in `ListUserActivityFeedsOptions` (SDK already supported it) - Forgejo: adds `&date=` query parameter to raw HTTP call - CachedClient passes through the `since` parameter in cache key - HomeView caller updated with `time.Time{}` (no behavior change) ### New: fetcher.go - **FetchActivityEvents()** — paginated fetch with PageSize=50, max 500 events, stops when fewer than page-size results returned - **AggregateActivityByDay()** — converts `[]*ActivityFeed` to `[]DailyActivity`, categorizing PR opens/closes and issue opens/closes by UTC-normalized day - Unknown op types are silently skipped; dates with zero matched events are excluded from output References: #190, #187 ## Testing - [x] 5 new aggregation tests: empty, single-day multi-type, multi-day ordering, unknown op types ignored, push-only ignored - [x] `golangci-lint run ./internal/activity/ ./internal/forge/` — 0 issues - [x] `go vet ./internal/...` — 0 issues - [x] `go test ./internal/activity/ ./internal/forge/ ./internal/tui/` — all pass
feat(activity): implement API fetcher with pagination and event aggregation
All checks were successful
Test and Release / lint (pull_request) Successful in 3m56s
Test and Release / test (pull_request) Successful in 9m47s
5b46640e5f
- Add  param to forge.Client.ListUserActivities across
  all implementations (gitea, forgejo, cached, mock)
- Gitea: passes Date field in ListUserActivityFeedsOptions
- Forgejo: adds &date= query parameter to raw HTTP call
- HomeView updated to pass zero time (existing behavior unchanged)
- Create fetcher.go with:
  - FetchActivityEvents(): paginated fetch with PageSize=50, max 500
  - AggregateActivityByDay(): categorizes PR opens/closes, issue
    opens/closes by UTC-normalized day
- 5 new tests covering empty, single day, multi-day, unknown types

Ref: #190, #187
fuzzy scheduled this pull request to auto merge when all checks succeed 2026-07-07 08:34:24 +00:00
the.auditor left a comment

Review

Result: Approved — no blocking issues.

Summary: Adds internal/activity/fetcher.go with FetchActivityEvents (paginated API fetch, PageSize=50, max 500) and AggregateActivityByDay (counts PR opens/closes and issue opens/closes per UTC day). Extends forge.Client interface with since time.Time parameter across all implementations (Gitea, Forgejo, CachedClient). Updates homeview caller with zero-time for backward compat. ROADMAP2.md updated — Phase 2 top-level items complete.

Notable design: additions/deletions aggregation not yet implemented (tracked as #193, unchecked in ROADMAP2). Expected — Push events currently ignored by aggregation.

Non-blocking:

  • #296 — Add godoc for exported FetchActivityEvents and AggregateActivityByDay

Checklist:

  • Correctness: Pagination logic correct, since passed through all client layers, aggregation counts correct per OpType
  • Completeness: Fetch + aggregation implemented, all forge clients updated
  • Test coverage: 5 aggregation tests (empty, single-day multi-type, multi-day ordering, unknown ignored, push-only ignored)
  • Error handling: Errors wrapped with page context
  • Maintainability: Clean separation — fetcher calls aggregator, client changes are minimal interface additions
  • Security: No concerns
## Review **Result: Approved** — no blocking issues. **Summary:** Adds `internal/activity/fetcher.go` with `FetchActivityEvents` (paginated API fetch, PageSize=50, max 500) and `AggregateActivityByDay` (counts PR opens/closes and issue opens/closes per UTC day). Extends `forge.Client` interface with `since time.Time` parameter across all implementations (Gitea, Forgejo, CachedClient). Updates homeview caller with zero-time for backward compat. ROADMAP2.md updated — Phase 2 top-level items complete. **Notable design:** `additions`/`deletions` aggregation not yet implemented (tracked as #193, unchecked in ROADMAP2). Expected — Push events currently ignored by aggregation. **Non-blocking:** - #296 — Add godoc for exported `FetchActivityEvents` and `AggregateActivityByDay` **Checklist:** - Correctness: ✅ Pagination logic correct, `since` passed through all client layers, aggregation counts correct per OpType - Completeness: ✅ Fetch + aggregation implemented, all forge clients updated - Test coverage: ✅ 5 aggregation tests (empty, single-day multi-type, multi-day ordering, unknown ignored, push-only ignored) - Error handling: ✅ Errors wrapped with page context - Maintainability: ✅ Clean separation — fetcher calls aggregator, client changes are minimal interface additions - Security: ✅ No concerns
fuzzy merged commit 5b46640e5f into main 2026-07-07 08:44:04 +00:00
fuzzy deleted branch phase02-fetcher 2026-07-07 08:44:04 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/steeper!295
No description provided.