feat(api): raw-data REST endpoints for comments, review-comments, label events (#98)#116
Open
jeffrey701 wants to merge 1 commit into
Open
feat(api): raw-data REST endpoints for comments, review-comments, label events (#98)#116jeffrey701 wants to merge 1 commit into
jeffrey701 wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add five read-only REST endpoints that expose the
comments,review_comments, andlabel_eventstables — currently populated by the webhook pipeline but unreachable through the API. Matches the proposed solution in the issue body verbatim.GET/api/v1/pulls/:owner/:repo/:number/commentscommentswherecomment_context = 'pr'GET/api/v1/pulls/:owner/:repo/:number/review-commentsreview_commentsGET/api/v1/issues/:owner/:repo/:number/commentscommentswherecomment_context = 'issue'GET/api/v1/pulls/:owner/:repo/:number/label-eventslabel_eventswheretarget_type = 'pr'GET/api/v1/issues/:owner/:repo/:number/label-eventslabel_eventswheretarget_type = 'issue'Each endpoint:
created_at ASC, comment_id ASC(ortimestamp ASC, id ASCfor label events).{t, i}tuple — first call passes nothing, subsequent calls echonext_cursor. Defaultlimit=50, capped at200.LOWER(repo_full_name)so case variants resolve to the same row (same pattern as the existing/pulls/.../files).404only when the parent PR / issue does not exist; an emptyitemsarray is valid.New module under
packages/das/src/api/comments/:comments.controller.ts— five@Gethandlers.comments.service.ts— five service methods +_ensurePrExists/_ensureIssueExists.cursor.ts—encodeCursor/decodeCursor/clampLimithelpers.Wired in
api.module.tsnext to the existingpulls/module.Related Issues
Closes #98
Type of Change
Testing
pnpm --filter=das build(vianest build) — clean compile, dist artifacts emitted underdist/api/comments/.npx tsc --noEmit— clean.(timestamp, id) > cursorpredicate.Test runtime not exercised against a live mirror in this branch; happy to add a Nest e2e test on request.
Checklist
@nestjs/swagger)