Skip to content

Commit 2e08ec5

Browse files
bitloianderdc
authored andcommitted
fix: clear solved_by_pr when issues reopen (#24)
1 parent 89c6e58 commit 2e08ec5

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

packages/das/src/webhook/github-fetcher.service.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -931,26 +931,29 @@ export class GitHubFetcherService implements OnModuleInit {
931931
break;
932932
}
933933

934-
await this.issueRepo.upsert(
935-
{
936-
repoFullName,
937-
issueNumber: issue.number,
938-
authorGithubId: String(issue.author?.databaseId ?? ""),
939-
authorLogin: issue.author?.login ?? null,
940-
authorAssociation: issue.authorAssociation ?? null,
941-
title: issue.title,
942-
state: issue.state, // OPEN / CLOSED
943-
stateReason: issue.stateReason ?? null,
944-
createdAt: issue.createdAt,
945-
closedAt: issue.closedAt ?? null,
946-
updatedAt: issue.updatedAt ?? null,
947-
lastEditedAt: issue.lastEditedAt ?? null,
948-
labels: (issue.labels?.nodes ?? []).map(
949-
(l: { name: string }) => l.name,
950-
),
951-
},
952-
["repoFullName", "issueNumber"],
953-
);
934+
const issueData: Partial<Issue> = {
935+
repoFullName,
936+
issueNumber: issue.number,
937+
authorGithubId: String(issue.author?.databaseId ?? ""),
938+
authorLogin: issue.author?.login ?? null,
939+
authorAssociation: issue.authorAssociation ?? null,
940+
title: issue.title,
941+
state: issue.state, // OPEN / CLOSED
942+
stateReason: issue.stateReason ?? null,
943+
createdAt: issue.createdAt,
944+
closedAt: issue.closedAt ?? null,
945+
updatedAt: issue.updatedAt ?? null,
946+
lastEditedAt: issue.lastEditedAt ?? null,
947+
labels: (issue.labels?.nodes ?? []).map(
948+
(l: { name: string }) => l.name,
949+
),
950+
};
951+
952+
if (issue.state === "OPEN") {
953+
issueData.solvedByPr = null;
954+
}
955+
956+
await this.issueRepo.upsert(issueData, ["repoFullName", "issueNumber"]);
954957

955958
// Upsert label events for this issue
956959
await this.saveLabelTimelineEvents(

packages/das/src/webhook/handlers/issue.handler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,26 @@ export class IssueHandler {
2020
// Skip pull request events delivered as issue events
2121
if (issue.pull_request) return;
2222

23+
const issueState = issue.state.toUpperCase();
2324
const data: Partial<Issue> = {
2425
repoFullName,
2526
issueNumber: issue.number,
2627
authorGithubId: String(issue.user.id),
2728
authorLogin: issue.user.login,
2829
authorAssociation: issue.author_association,
2930
title: issue.title ?? null,
30-
state: issue.state.toUpperCase(),
31+
state: issueState,
3132
stateReason: issue.state_reason?.toUpperCase() ?? null,
3233
createdAt: issue.created_at,
3334
closedAt: issue.closed_at ?? null,
3435
updatedAt: issue.updated_at ?? null,
3536
labels: (issue.labels ?? []).map((l: any) => l.name),
3637
};
3738

39+
if (issueState === "OPEN") {
40+
data.solvedByPr = null;
41+
}
42+
3843
// The `edited` action fires specifically for body or title changes.
3944
// Use the webhook's updated_at as the precise edit timestamp — for
4045
// other actions (labeled, closed, commented, etc.) don't touch

0 commit comments

Comments
 (0)