Skip to content

Instantly share code, notes, and snippets.

View ggalmazor's full-sized avatar
🏠
Working from home

Guillermo Gutiérrez ggalmazor

🏠
Working from home
View GitHub Profile
@ggalmazor
ggalmazor / gh_deployment_stats.mjs
Last active September 11, 2024 07:44
Computes stats about GitHub Deployments before and after a cutoff datetime.
import { Octokit } from '@octokit/rest';
import { getTime, isBefore, parseISO } from 'date-fns';
const octokit = new Octokit({ auth: 'token foobar' });
const durationSeconds = (a, b) => Math.round((getTime(parseISO(b)) - getTime(parseISO(a))) / 1000);
const isBeforeCutoff = (cutoffISO8601) => {
const cutoff = parseISO(cutoffISO8601);
return (deployment) => isBefore(parseISO(deployment.created_at), cutoff);
};