Created
June 17, 2020 10:01
-
-
Save msroot/7ecdc0b73889e542b9dd8b234e03fc1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'git' | |
g = Git.open('./') | |
g.branch('staging').checkout | |
report = [] | |
log = g.log(900000000) | |
log.each {|commit| | |
next unless commit.commit? | |
e = commit.date | |
report << [e.to_i, e.hour] | |
} | |
html = %( | |
<html> | |
<head> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
google.charts.load('current', {'packages':['corechart']}); | |
google.charts.setOnLoadCallback(drawChart); | |
var report_data = #{report}; | |
function drawChart () { | |
var data = new google.visualization.DataTable(); | |
data.addColumn('datetime', 'Dates'); | |
data.addColumn('number', 'Commit Timestamp'); | |
report_data.forEach(e => { | |
data.addRows( | |
[[new Date(e[0] * 1000), e[1]]] | |
); | |
}); | |
var options = { | |
width: 800, | |
height: 500, | |
chart: { | |
title: 'Git Commits' | |
}, | |
hAxis: {title: 'Dates'}, | |
vAxis: {title: 'Hours'} | |
}; | |
var chart = new google.visualization.ScatterChart(document.getElementById('chart_div')); | |
chart.draw(data, options); | |
} | |
</script> | |
</head> | |
<body> | |
<div id="chart_div" style="width: 900px; height: 500px;"></div> | |
</body> | |
</html> | |
) | |
file_path = "report.html" | |
file = File.open(file_path, "w") | |
file.write(html) | |
# `open #{file_path}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment