Forked from gregorynicholas/google-apps-script-github-burndown.js
Created
January 16, 2019 12:26
-
-
Save schlos/8259a96cc71a77ac3a5c59e46387a026 to your computer and use it in GitHub Desktop.
google apps script to create a github issues burndown chart
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
/** | |
* Heads to github fetches milestone info, and adds rows to spreadsheet | |
*/ | |
function updateBugCounts() { | |
var resp = UrlFetchApp.fetch("https://api.github.com/repos/DramaFever/www/milestones?access_token=XXX"); | |
var jsonStr = resp.getContentText(); | |
var milestones = Utilities.jsonParse(jsonStr); | |
var dataSs = SpreadsheetApp.openById("YYY"); | |
var sheet = dataSs.getSheetByName('Raw Data'); | |
for (var i = 0; i < milestones.length; i++) { | |
milestone = milestones[i]; | |
sheet.appendRow([milestone.title, Utilities.formatDate(new Date(), "US/Eastern", "yyyy-MM-dd"), milestone.open_issues, milestone.closed_issues]) | |
} | |
} | |
/** | |
* get the full data table (dates and counts) for a all milestones as extracted from the raw data sheet | |
*/ | |
function getDataTable() { | |
var dataSs = SpreadsheetApp.openById("0Ag86SykVA-evdDdIbnR4emhvVGxHYnJKejczWDhMYWc"); | |
var sheet = dataSs.getSheetByName('Raw Data'); | |
var cells = sheet.getDataRange().getValues(); | |
var retval = Charts.newDataTable() | |
.addColumn(Charts.ColumnType.STRING, "Milestone") | |
.addColumn(Charts.ColumnType.STRING, "Date") | |
.addColumn(Charts.ColumnType.NUMBER, "Open") | |
.addColumn(Charts.ColumnType.NUMBER, "Closed"); | |
for (var row = 1; row < cells.length; row++) { // skip header | |
retval.addRow([cells[row][0], Utilities.formatDate(cells[row][1], "US/Eastern", "yyyy-MM-dd"), cells[row][2], cells[row][3]]); | |
} | |
return retval.build(); | |
} | |
function doGet() { | |
var data = getDataTable(); | |
var dataViewDefinition = Charts.newDataViewDefinition() | |
.setColumns([1, 2, 3]) | |
.build(); | |
var chart = Charts.newAreaChart() | |
.setDataViewDefinition(dataViewDefinition) | |
.setTitle("Burndown Chart") | |
.setStacked() | |
.setDimensions(800, 500) | |
.build() | |
var control = Charts.newCategoryFilter() | |
.setFilterColumnLabel("Milestone") | |
.setAllowNone(false) | |
.setAllowMultiple(false) | |
.build(); | |
var dashboard = Charts.newDashboardPanel() | |
.setDataTable(data) | |
.bind(control, chart) | |
.build(); | |
var uiApp = UiApp.createApplication().setTitle("GitHub Burndown"); | |
var panel = uiApp.createHorizontalPanel() | |
.setVerticalAlignment(UiApp.VerticalAlignment.MIDDLE) | |
.setSpacing(50); | |
panel.add(control); | |
panel.add(chart); | |
dashboard.add(panel); | |
uiApp.add(dashboard); | |
return uiApp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment