Skip to content

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

Description

@kiannidev

Description

GET/POST /api/v1/miners/:githubId/pulls always sorts results by p.created_at DESC. For MERGED and CLOSED PRs that enter the scoring window via merged_at / closed_at, this ranks recently merged/closed work below older OPEN PRs and makes validator responses look stale.

Steps to Reproduce

  1. Mirror two PRs by the same miner in the same repo:
    • PR A: OPEN, created_at = 2 days ago
    • PR B: CLOSED, created_at = 60 days ago, closed_at = 1 day ago
  2. Call GET /api/v1/miners/{id}/pulls?since= (30 days ago).
  3. PR A appears before PR B even though B closed more recently.

Expected Behavior

Sort by the timestamp relevant to each state: created_at for OPEN, merged_at for MERGED, closed_at for CLOSED.

Actual Behavior

ORDER BY p.created_at DESC

Environment

  • OS: Linux
  • Runtime/Node version: Node 20

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions