Skip to content

fix(miners): sort pull requests by state-relevant timestamp - #194

Closed
Yurii214 wants to merge 1 commit into
entrius:testfrom
Yurii214:fix/186-miners-pr-state-sort
Closed

fix(miners): sort pull requests by state-relevant timestamp#194
Yurii214 wants to merge 1 commit into
entrius:testfrom
Yurii214:fix/186-miners-pr-state-sort

Conversation

@Yurii214

@Yurii214 Yurii214 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes [bug] miners API: pull requests sorted by created_at instead of state-relevant timestamp #186: miner pull request listings now sort by the timestamp relevant to each PR state (merged_at for MERGED, closed_at for CLOSED, created_at for OPEN).
  • Applies the same state-relevant timestamp to the CLOSED branch of the since window filter (was incorrectly using created_at).
  • Aligns keyset pagination cursors with the sort key on both GET /miners/:id/pulls and POST /miners/:id/pulls (per-repo path), so paginated pages stay ordered consistently.

Shared SQL fragments (PR_SORT_AT, PR_ORDER_BY, PR_SINCE_WINDOW*) keep the GET and POST paths identical.

Why

Validators window PRs by since and expect recently merged/closed work to rank above older OPEN PRs. Sorting everything by created_at made stale-looking responses when a CLOSED PR had an old created_at but a recent closed_at.

What might break

  • On-disk / API shape: none — response fields unchanged.
  • Pagination cursors: cursors issued before this change used created_at as the page key; clients mid-pagination may need to restart from the first page once. New cursors encode the state-relevant sort timestamp in the existing cursor field.

Type of Change

  • Bug fix

Testing

  • npm run build in packages/das
  • npm run lint in packages/das
  • npm run format:check in packages/das
  • Manual repro: CLOSED PR with old created_at and recent closed_at now sorts above older OPEN PRs when both are in the scoring window

Fixes #186

Use merged_at / closed_at / created_at for ORDER BY, since-window
filtering, and keyset pagination on both GET and POST pull endpoints.
Aligns paginated cursors with the same sort key (entrius#186).

Fixes entrius#186
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jun 22, 2026
@anderdc anderdc closed this Jun 24, 2026
@Yurii214

Copy link
Copy Markdown
Contributor Author

Hi @anderdc — thanks for looking at this. Could you share why #194 was closed?
The sort/pagination fix for #186 isn’t on test yet, and I want to adjust
approach rather than resubmit the same thing. Happy to scope down or wait if
you’re handling #186 internally. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] miners API: pull requests sorted by created_at instead of state-relevant timestamp

3 participants