Skip to content

feat(api): raw-data REST endpoints for comments, review-comments, label events (#98)#116

Open
jeffrey701 wants to merge 1 commit into
entrius:testfrom
jeffrey701:feat/raw-data-comments-endpoints-98
Open

feat(api): raw-data REST endpoints for comments, review-comments, label events (#98)#116
jeffrey701 wants to merge 1 commit into
entrius:testfrom
jeffrey701:feat/raw-data-comments-endpoints-98

Conversation

@jeffrey701
Copy link
Copy Markdown

Summary

Add five read-only REST endpoints that expose the comments, review_comments, and label_events tables — currently populated by the webhook pipeline but unreachable through the API. Matches the proposed solution in the issue body verbatim.

Method Path Source
GET /api/v1/pulls/:owner/:repo/:number/comments comments where comment_context = 'pr'
GET /api/v1/pulls/:owner/:repo/:number/review-comments review_comments
GET /api/v1/issues/:owner/:repo/:number/comments comments where comment_context = 'issue'
GET /api/v1/pulls/:owner/:repo/:number/label-events label_events where target_type = 'pr'
GET /api/v1/issues/:owner/:repo/:number/label-events label_events where target_type = 'issue'

Each endpoint:

  • Returns rows ordered by created_at ASC, comment_id ASC (or timestamp ASC, id ASC for label events).
  • Cursor pagination via opaque base64url-encoded {t, i} tuple — first call passes nothing, subsequent calls echo next_cursor. Default limit=50, capped at 200.
  • Filters with LOWER(repo_full_name) so case variants resolve to the same row (same pattern as the existing /pulls/.../files).
  • Returns 404 only when the parent PR / issue does not exist; an empty items array is valid.

New module under packages/das/src/api/comments/:

  • comments.controller.ts — five @Get handlers.
  • comments.service.ts — five service methods + _ensurePrExists / _ensureIssueExists.
  • cursor.tsencodeCursor / decodeCursor / clampLimit helpers.

Wired in api.module.ts next to the existing pulls/ module.

Related Issues

Closes #98

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Testing

  • pnpm --filter=das build (via nest build) — clean compile, dist artifacts emitted under dist/api/comments/.
  • npx tsc --noEmit — clean.
  • Manual SQL pasted into a local Postgres mirror to confirm the keyset ordering and (timestamp, id) > cursor predicate.

Test runtime not exercised against a live mirror in this branch; happy to add a Nest e2e test on request.

Checklist

  • I have read the Contributing Guide
  • Code builds without errors
  • New and existing tests pass (if applicable)
  • Documentation updated (if applicable — endpoints auto-document via @nestjs/swagger)
  • No unnecessary dependencies added

…el events (entrius#98)

Add five chronological-cursor-paginated GET endpoints under `api/v1`:

- GET /pulls/:owner/:repo/:number/comments        (comment_context='pr')
- GET /pulls/:owner/:repo/:number/review-comments
- GET /pulls/:owner/:repo/:number/label-events    (target_type='pr')
- GET /issues/:owner/:repo/:number/comments       (comment_context='issue')
- GET /issues/:owner/:repo/:number/label-events   (target_type='issue')

Each query is `(created_at|timestamp, id) > cursor ORDER BY ts ASC, id
ASC LIMIT :limit+1` and uses the existing indexes — no schema or index
changes. Default limit 50, cap 200. Cursor is an opaque base64url JSON
`{t,i}` tuple; first call passes nothing. Repo-name matching is
case-insensitive (lower-bound lookup through the small `repos` table)
to match the existing pulls/files endpoint. 404 is returned only when
the parent PR/issue is unknown; an empty array is valid.

Module: new `api/comments/` (controller + service + cursor util),
wired in `api.module.ts` next to the existing `pulls/` module.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raw-data REST endpoints for comments, review comments, and label events

1 participant