Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/das/src/entities/ReviewComment.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class ReviewComment {
@Column({ name: "reviewer_login", nullable: true })
reviewerLogin: string;

@Column({ name: "reviewer_association", nullable: true })
reviewerAssociation: string | null;

@Column({ name: "review_id", type: "bigint", nullable: true })
reviewId: string | null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class ReviewCommentHandler {
prNumber: payload.pull_request.number,
reviewerGithubId: String(comment.user.id),
reviewerLogin: comment.user.login,
reviewerAssociation: comment.author_association ?? null,
reviewId: comment.pull_request_review_id
? String(comment.pull_request_review_id)
: null,
Expand Down
3 changes: 3 additions & 0 deletions packages/db/06_review_comments.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CREATE TABLE IF NOT EXISTS review_comments (
pr_number INTEGER NOT NULL,
reviewer_github_id VARCHAR(255),
reviewer_login VARCHAR(255),
reviewer_association VARCHAR(20),
review_id BIGINT,
path VARCHAR(1024),
line INTEGER,
Expand All @@ -19,6 +20,8 @@ CREATE TABLE IF NOT EXISTS review_comments (
PRIMARY KEY (repo_full_name, comment_id)
);

ALTER TABLE review_comments ADD COLUMN IF NOT EXISTS reviewer_association VARCHAR(20);

CREATE INDEX IF NOT EXISTS idx_review_comments_pr ON review_comments(repo_full_name, pr_number);
CREATE INDEX IF NOT EXISTS idx_review_comments_reviewer ON review_comments(reviewer_github_id);
CREATE INDEX IF NOT EXISTS idx_review_comments_review ON review_comments(review_id);
18 changes: 17 additions & 1 deletion packages/db/20_view_contributor_repo_roles.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Latest known association per contributor per repo.
-- Uses every table that stores GitHub's author_association/reviewer_association:
-- PR authors, issue authors, submitted reviews, and issue/PR thread comments.
-- PR authors, issue authors, submitted reviews, issue/PR thread comments, and
-- inline PR review comments.
-- Rows without a stored association are ignored; label views should use the
-- latest known role, not let a missing observation erase earlier evidence.

Expand Down Expand Up @@ -68,5 +69,20 @@ FROM (
WHERE author_github_id IS NOT NULL
AND author_github_id <> ''
AND author_association IS NOT NULL

UNION ALL

SELECT
repo_full_name,
reviewer_github_id AS author_github_id,
reviewer_login AS author_login,
reviewer_association AS author_association,
COALESCE(updated_at, created_at) AS observed_at,
30 AS source_rank,
'review_comment:' || comment_id::text AS source_key
FROM review_comments
WHERE reviewer_github_id IS NOT NULL
AND reviewer_github_id <> ''
AND reviewer_association IS NOT NULL
) combined
ORDER BY repo_full_name, author_github_id, observed_at DESC, source_rank DESC, source_key DESC;