diff --git a/packages/das/src/webhook/github-fetcher.service.ts b/packages/das/src/webhook/github-fetcher.service.ts index 98c8de4..d58e18f 100644 --- a/packages/das/src/webhook/github-fetcher.service.ts +++ b/packages/das/src/webhook/github-fetcher.service.ts @@ -931,26 +931,29 @@ export class GitHubFetcherService implements OnModuleInit { break; } - await this.issueRepo.upsert( - { - repoFullName, - issueNumber: issue.number, - authorGithubId: String(issue.author?.databaseId ?? ""), - authorLogin: issue.author?.login ?? null, - authorAssociation: issue.authorAssociation ?? null, - title: issue.title, - state: issue.state, // OPEN / CLOSED - stateReason: issue.stateReason ?? null, - createdAt: issue.createdAt, - closedAt: issue.closedAt ?? null, - updatedAt: issue.updatedAt ?? null, - lastEditedAt: issue.lastEditedAt ?? null, - labels: (issue.labels?.nodes ?? []).map( - (l: { name: string }) => l.name, - ), - }, - ["repoFullName", "issueNumber"], - ); + const issueData: Partial = { + repoFullName, + issueNumber: issue.number, + authorGithubId: String(issue.author?.databaseId ?? ""), + authorLogin: issue.author?.login ?? null, + authorAssociation: issue.authorAssociation ?? null, + title: issue.title, + state: issue.state, // OPEN / CLOSED + stateReason: issue.stateReason ?? null, + createdAt: issue.createdAt, + closedAt: issue.closedAt ?? null, + updatedAt: issue.updatedAt ?? null, + lastEditedAt: issue.lastEditedAt ?? null, + labels: (issue.labels?.nodes ?? []).map( + (l: { name: string }) => l.name, + ), + }; + + if (issue.state === "OPEN") { + issueData.solvedByPr = null; + } + + await this.issueRepo.upsert(issueData, ["repoFullName", "issueNumber"]); // Upsert label events for this issue await this.saveLabelTimelineEvents( diff --git a/packages/das/src/webhook/handlers/issue.handler.ts b/packages/das/src/webhook/handlers/issue.handler.ts index 98f9090..a94edbc 100644 --- a/packages/das/src/webhook/handlers/issue.handler.ts +++ b/packages/das/src/webhook/handlers/issue.handler.ts @@ -20,6 +20,7 @@ export class IssueHandler { // Skip pull request events delivered as issue events if (issue.pull_request) return; + const issueState = issue.state.toUpperCase(); const data: Partial = { repoFullName, issueNumber: issue.number, @@ -27,7 +28,7 @@ export class IssueHandler { authorLogin: issue.user.login, authorAssociation: issue.author_association, title: issue.title ?? null, - state: issue.state.toUpperCase(), + state: issueState, stateReason: issue.state_reason?.toUpperCase() ?? null, createdAt: issue.created_at, closedAt: issue.closed_at ?? null, @@ -35,6 +36,10 @@ export class IssueHandler { labels: (issue.labels ?? []).map((l: any) => l.name), }; + if (issueState === "OPEN") { + data.solvedByPr = null; + } + // The `edited` action fires specifically for body or title changes. // Use the webhook's updated_at as the precise edit timestamp — for // other actions (labeled, closed, commented, etc.) don't touch