Created
October 5, 2017 19:27
-
-
Save lukekarrys/1d2000b679115631ae9a5b72586d287d to your computer and use it in GitHub Desktop.
Get percentage of each day of the week with commits from graph.
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
javascript:(()=>{const e=["Sun","Mon","Tues","Wed","Thur","Fri","Sat"],r=[...document.querySelectorAll(".js-calendar-graph-svg > g > g")].reduce((e,r)=>[...r.querySelectorAll("rect.day")].reduce((e,r,t)=>(e[t][0]+="0"===r.getAttribute("data-count")?0:1,e[t][1]+=1,e),e),e.map(()=>[0,0])).reduce((r,t,c)=>(r[e[c]]=+(t[0]/t[1]*100).toFixed(3),r),{});console.log(r)})(); |
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
(() => { | |
const days = ['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat'] | |
const res = [...document.querySelectorAll('.js-calendar-graph-svg > g > g')].reduce((acc, week) => { | |
return [...week.querySelectorAll('rect.day')].reduce((acc, day, index) => { | |
acc[index][0] += day.getAttribute('data-count') === "0" ? 0 : 1; | |
acc[index][1] += 1; | |
return acc | |
}, acc) | |
}, days.map(() => [0, 0])).reduce((acc, day, index) => { | |
acc[days[index]] = +((day[0] / day[1] * 100).toFixed(3)) | |
return acc | |
}, {}) | |
console.log(res) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment