Created
April 8, 2018 07:31
-
-
Save joyeecheung/34d1660322adf2e47211757916dc269f to your computer and use it in GitHub Desktop.
Get frequency of committed time, in UTC hours
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const child_process = require('child_process'); | |
const log = child_process.spawnSync('git', ['log', '--format=%cI', '-n', '10000'], { | |
cwd: process.cwd() | |
}); | |
const dates = log.stdout.toString().trim(); | |
const hours = dates.split('\n').map(d => new Date(d).getUTCHours()); | |
const map = new Map(); | |
for (const h of hours) { | |
if (map.has(h)) { | |
map.set(h, map.get(h) + 1); | |
} else { | |
map.set(h, 1); | |
} | |
} | |
const pairs = [...map.entries()].sort((a, b) => a[1] > b[1] ? -1 : 1); | |
console.log(pairs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment