diff --git a/packages/das/src/entities/ReviewComment.entity.ts b/packages/das/src/entities/ReviewComment.entity.ts index 8746bec..0541d8e 100644 --- a/packages/das/src/entities/ReviewComment.entity.ts +++ b/packages/das/src/entities/ReviewComment.entity.ts @@ -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; diff --git a/packages/das/src/webhook/handlers/review-comment.handler.ts b/packages/das/src/webhook/handlers/review-comment.handler.ts index 3b957da..3a7d6cd 100644 --- a/packages/das/src/webhook/handlers/review-comment.handler.ts +++ b/packages/das/src/webhook/handlers/review-comment.handler.ts @@ -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, diff --git a/packages/db/06_review_comments.sql b/packages/db/06_review_comments.sql index 97870b6..3290451 100644 --- a/packages/db/06_review_comments.sql +++ b/packages/db/06_review_comments.sql @@ -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, @@ -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); diff --git a/packages/db/20_view_contributor_repo_roles.sql b/packages/db/20_view_contributor_repo_roles.sql index 1e084df..d4b36e8 100644 --- a/packages/db/20_view_contributor_repo_roles.sql +++ b/packages/db/20_view_contributor_repo_roles.sql @@ -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. @@ -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;