-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathadd-late-review-label.js
More file actions
56 lines (54 loc) · 1.47 KB
/
add-late-review-label.js
File metadata and controls
56 lines (54 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {
paginateAllOpenPullRequests
} from "../main-zd3p3dtn.js";
import {
LATE_REVIEW,
SECONDS_IN_A_DAY
} from "../main-9c2herm2.js";
import {
require_bluebird
} from "../main-ttmzs6m5.js";
import {
HelperInputs
} from "../main-8h70j5cy.js";
import {
octokit
} from "../main-4c5nddsb.js";
import {
context
} from "../main-6avxv4a6.js";
import"../main-9m3k9gt0.js";
import"../main-q70tmm6g.js";
import {
__toESM
} from "../main-wckvcay0.js";
// src/helpers/add-late-review-label.ts
var import_bluebird = __toESM(require_bluebird(), 1);
class AddLateReviewLabel extends HelperInputs {
}
var addLateReviewLabel = async ({ days = "1" }) => {
const openPullRequests = await paginateAllOpenPullRequests();
return import_bluebird.map(openPullRequests, (pr) => {
if (!isLabelNeeded(pr, Number(days))) {
return;
}
return octokit.issues.addLabels({
labels: [LATE_REVIEW],
issue_number: pr.number,
...context.repo
});
});
};
var isLabelNeeded = ({ requested_reviewers, requested_teams, updated_at }, days) => {
const last_updated = new Date(updated_at);
const now = new Date;
const timeSinceLastUpdated = now.getTime() - last_updated.getTime();
const dayThreshold = days * SECONDS_IN_A_DAY;
const isWaitingOnReviewers = Boolean(requested_reviewers || requested_teams);
return timeSinceLastUpdated > dayThreshold && isWaitingOnReviewers;
};
export {
addLateReviewLabel,
AddLateReviewLabel
};
//# debugId=9F00FD243F8100D664756E2164756E21