Skip to content

feat: persist closed_at timestamp for pull requests (#396)#400

Open
EternalVision-AI wants to merge 1 commit intoentrius:testfrom
EternalVision-AI:feature/add-closed-at-to-pull-request
Open

feat: persist closed_at timestamp for pull requests (#396)#400
EternalVision-AI wants to merge 1 commit intoentrius:testfrom
EternalVision-AI:feature/add-closed-at-to-pull-request

Conversation

@EternalVision-AI
Copy link
Copy Markdown

@EternalVision-AI EternalVision-AI commented Apr 13, 2026

Summary

Add closed_at field to the PullRequest dataclass and persist it to the database so the API can expose it to the frontend for 35-day evaluation window filtering.

The GraphQL query already fetches closedAt from GitHub, but it was only used during validation filtering in try_add_open_or_closed_pr() and never stored. This pipes the existing value through the dataclass into the bulk upsert query.

Changes:

  • Add closed_at: Optional[datetime] field to PullRequest dataclass
  • Parse closedAt from GraphQL response in from_graphql_response()
  • Add closed_at column to BULK_UPSERT_PULL_REQUESTS INSERT and ON CONFLICT UPDATE
  • Add pr.closed_at to the values tuple in repository.py
  • Add unit tests covering CLOSED, MERGED, and OPEN PR states

Migration required:

ALTER TABLE pull_requests ADD COLUMN IF NOT EXISTS closed_at TIMESTAMPTZ;

Note: GitHub sets closedAt for both CLOSED and MERGED PRs (merging closes a PR), so the field is populated for both states and None only for OPEN PRs.

Related Issues

Fixes #396

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Tests added/updated
  • Manually tested

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

The GraphQL query already fetches closedAt from GitHub but it was only
used for validation filtering and never stored. This pipes the existing
value through the PullRequest dataclass into the database so the API
can expose it to the frontend for 35-day evaluation window filtering.

Requires: ALTER TABLE pull_requests ADD COLUMN IF NOT EXISTS closed_at TIMESTAMPTZ;

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add closed_at field to pull request storage for 35-day window filtering

1 participant