Skip to content

Commit

Permalink
♻️ Move deleting issues to summary
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Dec 2, 2020
1 parent fcc2514 commit c4afb56
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
34 changes: 34 additions & 0 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,38 @@ ${config.summaryEndHtmlComment || "<!--end: status pages-->"}${endText}`;
);

push();

if (!config.skipDeleteIssues) {
// Find all the opened issues that shouldn't have opened
// Say, Upptime found a down monitor and it was back up within 5 min
const issuesRecentlyClosed = await octokit.issues.listForRepo({
owner,
repo,
state: "closed",
labels: "status",
per_page: 10,
});
console.log("Found recently closed issues", issuesRecentlyClosed.data.length);
for await (const issue of issuesRecentlyClosed.data) {
if (
// If this issue was closed within 15 minutes
new Date(issue.closed_at).getTime() - new Date(issue.created_at).getTime() < 900000 &&
// It has 1 comment (the default Upptime one)
issue.comments === 1
) {
try {
console.log("Trying to delete issue", issue.number, issue.node_id);
const result = await octokit.graphql(`
mutation deleteIssue {
deleteIssue(input:{issueId:"${issue.node_id}"}) {
clientMutationId
}
}`);
console.log("Success", result);
} catch (error) {
console.log("Error deleting this issue", error);
}
}
}
}
};
34 changes: 0 additions & 34 deletions src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,40 +248,6 @@ generator: Upptime <https://github.com/upptime/upptime>
}
push();

if (!config.skipDeleteIssues) {
// Find all the opened issues that shouldn't have opened
// Say, Upptime found a down monitor and it was back up within 5 min
const issuesRecentlyClosed = await octokit.issues.listForRepo({
owner,
repo,
state: "closed",
labels: "status",
per_page: 10,
});
console.log("Found recently closed issues", issuesRecentlyClosed.data.length);
for await (const issue of issuesRecentlyClosed.data) {
if (
// If this issue was closed within 15 minutes
new Date(issue.closed_at).getTime() - new Date(issue.created_at).getTime() < 900000 &&
// It has 1 comment (the default Upptime one)
issue.comments === 1
) {
try {
console.log("Trying to delete issue", issue.number, issue.node_id);
const result = await octokit.graphql(`
mutation deleteIssue {
deleteIssue(input:{issueId:"${issue.node_id}"}) {
clientMutationId
}
}`);
console.log("Success", result);
} catch (error) {
console.log("Error deleting this issue", error);
}
}
}
}

if (hasDelta) generateSummary();
};

Expand Down

0 comments on commit c4afb56

Please sign in to comment.