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
import { daysAgoFromToday } from "https://esm.town/v/ramkarthik/daysAgoFromToday";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export const staleGithubPRs = async (
owner: string,
repo: string,
token: string,
staleSinceDaysAgo: number,
) => {
let options = {
"headers": {
"Authorization": "Bearer " + token,
"X-GitHub-Api-Version": "2022-11-28",
},
};
let data = await fetchJSON(
`https://api.github.com/repos/${owner}/${repo}/pulls`,
options,
);
let pullRequests = [];
let staleDate = daysAgoFromToday(staleSinceDaysAgo);
if (data && data.length > 0) {
let prs = data?.filter((d) => d.updated_at <= staleDate).map((d) => {
return {
url: d.html_url,
title: d.title,
author: d.user.login,
created_at: d.created_at,
updated_at: d.updated_at,
reviewers: d.requested_reviewers.map((r) => r.login),
head: d.head.ref,
base: d.base.ref,
};
});
pullRequests.push(...prs);
}
return pullRequests;
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023