Duplicate check
| Item |
Relation |
| #71 (closed) |
Backfill GraphQL stops at created_at — ingestion layer, not miner query |
| #16 / #15 (closed) |
Backfill lookback window — not REST miners API |
| #100 (open) |
Pagination — orthogonal |
| No open/closed issue |
Miner /pulls CLOSED branch uses created_at |
Description
GET/POST /api/v1/miners/:githubId/pulls applies inconsistent time windows across PR states. MERGED PRs correctly use merged_at >= since. CLOSED (unmerged) PRs use created_at >= since, while the sibling /issues endpoint uses closed_at >= since for closed issues. Old PRs closed inside the scoring window but opened before since are omitted from miner pull results.
Steps to Reproduce
- Mirror a repo with a miner-authored PR:
created_at = 60 days ago, closed_at = 5 days ago, state = CLOSED (not merged).
- Call
GET /api/v1/miners/{authorId}/pulls?since= (ISO timestamp 30 days ago).
- Call
GET /api/v1/miners/{authorId}/issues?since= (same timestamp).
- The closed issue appears (
closed_at >= since ); the closed PR does not (created_at < since).
- Repeat with
POST .../pulls and since_by_repo — same filter in getPullRequestsByRepo.
Expected Behavior
CLOSED PRs should enter the window when closed_at >= since, matching issues and matching how MERGED uses merged_at.
Actual Behavior
-- miners.service.ts (GET and POST variants)
(p.state = 'OPEN' AND p.created_at >= $2)
OR (p.state = 'MERGED' AND p.merged_at >= $2)
OR (p.state = 'CLOSED' AND p.created_at >= $2) -- should use closed_at
Issues endpoint for comparison:
(i.state = 'CLOSED' AND i.closed_at >= $2)
Environment
- OS: Linux
- Runtime/Node version: Node 20
- Browser (if applicable): N/A
Additional Context
Files: packages/das/src/api/miners/miners.service.ts (lines ~186–190 and ~235–238)
Fix: Change CLOSED branch to p.closed_at >= $2 (and w.since in POST path); ensure closed_at is populated on webhook upsert (already stored in pull-request.handler.ts).
PR scope: ~5–15 lines + integration test or SQL fixture.
Duplicate check
created_at— ingestion layer, not miner query/pullsCLOSEDbranch usescreated_atDescription
GET/POST /api/v1/miners/:githubId/pullsapplies inconsistent time windows across PR states.MERGEDPRs correctly usemerged_at >= since.CLOSED(unmerged) PRs usecreated_at >= since, while the sibling/issuesendpoint usesclosed_at >= sincefor closed issues. Old PRs closed inside the scoring window but opened beforesinceare omitted from miner pull results.Steps to Reproduce
created_at= 60 days ago,closed_at= 5 days ago,state=CLOSED(not merged).GET /api/v1/miners/{authorId}/pulls?since=(ISO timestamp 30 days ago).GET /api/v1/miners/{authorId}/issues?since=(same timestamp).closed_at >= since); the closed PR does not (created_at < since).POST .../pullsandsince_by_repo— same filter ingetPullRequestsByRepo.Expected Behavior
CLOSEDPRs should enter the window whenclosed_at >= since, matching issues and matching howMERGEDusesmerged_at.Actual Behavior
Issues endpoint for comparison:
Environment
Additional Context
Files:
packages/das/src/api/miners/miners.service.ts(lines ~186–190 and ~235–238)Fix: Change
CLOSEDbranch top.closed_at >= $2(andw.sincein POST path); ensureclosed_atis populated on webhook upsert (already stored inpull-request.handler.ts).PR scope: ~5–15 lines + integration test or SQL fixture.