type Github = {
token: string;
};
/**
* Get the hourly commit count for each day
* Each array contains the day number, hour number, and number of commits:
* `0-6`: Sunday - Saturday
* `0-23`: Hour of day
* Number of commits
For example, `[2, 14, 25]` indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.
*/
export async function main(auth: Github, owner: string, repo: string) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/stats/punch_card`
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* Get the hourly commit count for each day
* Each array contains the day number, hour number, and number of commits:
* `0-6`: Sunday - Saturday
* `0-23`: Hour of day
* Number of commits
For example, `[2, 14, 25]` indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.
*/
export async function main(auth: Github, owner: string, repo: string) {
const url = new URL(
`https://api.github.com/repos/${owner}/${repo}/stats/punch_card`
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 927 days ago