Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update locking script to add comments for issues updated within the last two weeks #99

Merged
merged 1 commit into from
Aug 1, 2023
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ translation files changed, directing the user to the crowdin project.
### Locks

The script will also lock issues and pull requests that have been closed for 3
months. If the issue was updated in the last month, a comment will be posted
months. If the issue was updated in the last two weeks, a comment will be posted
suggesting opening a new issue to continue the discussion.

## Usage
Expand Down
10 changes: 5 additions & 5 deletions src/lock.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { addComment, fetchClosedOldIssuesAndPRs, lockIssue } from "./github.ts";

const MILLISECONDS_IN_A_MONTH = 1000 * 60 * 60 * 24 * 30;
const MILLISECONDS_IN_A_DAY = 1000 * 60 * 60 * 24;

// adds a comment and locks old issues and PRs
export const run = async () => {
const oneMonthAgo = new Date(Date.now() - MILLISECONDS_IN_A_MONTH);
const threeMonthsAgo = new Date(Date.now() - MILLISECONDS_IN_A_MONTH * 3);
const twoWeeksAgo = new Date(Date.now() - MILLISECONDS_IN_A_DAY * 14);
const threeMonthsAgo = new Date(Date.now() - MILLISECONDS_IN_A_DAY * 90);
const issues = await fetchClosedOldIssuesAndPRs(threeMonthsAgo);
return Promise.all(
issues.items.map(
Expand All @@ -18,8 +18,8 @@ export const run = async () => {
) => {
const lockedSuccessfully = await lockIssue(issue.number, "resolved");

// if the issue was updated in the last month, we add a comment
if (lockedSuccessfully && new Date(issue.updated_at) > oneMonthAgo) {
// if the issue was updated in the two weeks, we add a comment
if (lockedSuccessfully && new Date(issue.updated_at) > twoWeeksAgo) {
await addComment(
issue.number,
`We lock ${
Expand Down