Last active
November 15, 2018 06:15
-
-
Save faishal/c3b17bdcce4bf4d440442e936c88f120 to your computer and use it in GitHub Desktop.
Zenhub Pipeline report
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
var pipelines = document.getElementsByClassName( 'zhc-pipeline' ); | |
var line_break = '\n\r'; | |
var report = ''; | |
var epics_data = {}; | |
for ( var i = 0; i < pipelines.length; i ++ ) { | |
var pipeline = pipelines[i]; | |
var issues = $( '.zhc-issue-cards__cell', pipeline ); | |
var status = $( '.zhc-pipeline-header__title', pipeline ).textContent; | |
if ( issues ) { | |
issues = issues.parentElement.children; | |
report += $( '.zhc-pipeline-header__title', pipeline ).textContent + line_break; | |
} else { | |
continue; | |
} | |
for ( var j = 0; j < issues.length; j ++ ) { | |
var title = $( '.zhc-issue-card__issue-title', issues[j] ); | |
var no = $( '.zhc-issue-card__issue-number', issues[j] ); | |
var point = $( '.zhc-badge__value', issues[j] ); | |
var epic = $( '.zhc-issue-card__epics__title', issues[j] ); | |
var epic_title = 'Misc'; | |
if ( epic ) { | |
epic_title = epic.textContent; | |
} | |
if(!epics_data[epic_title]){ | |
epics_data[epic_title] = {}; | |
} | |
if(!epics_data[epic_title][status]){ | |
epics_data[epic_title][status] = []; | |
} | |
var line = ''; | |
if ( no ) { | |
line += '#' + no.textContent + ' '; | |
} | |
if ( title ) { | |
line += title.textContent + ' '; | |
} | |
if ( point ) { | |
line += ' - ' + point.textContent ; | |
} | |
report += line + line_break; | |
epics_data[epic_title][status].push(line); | |
} | |
report += line_break + line_break; | |
} | |
var epic_titles = Object.keys( epics_data ); | |
var epic_reports = ''; | |
for ( var i = 0; i < epic_titles.length; i ++ ) { | |
var epic_title = epic_titles[i]; | |
var epic = epics_data[epic_title]; | |
var all_status = Object.keys( epic ); | |
epic_reports += '-'.repeat( epic_title.length ) + line_break; | |
epic_reports += epic_title + line_break; | |
epic_reports += '-'.repeat( epic_title.length ) + line_break; | |
for ( var j = 0; j < all_status.length; j ++ ) { | |
var status = all_status[j]; | |
epic_reports += '-'.repeat( status.length ) + line_break; | |
epic_reports += status + line_break; | |
epic_reports += '-'.repeat( status.length ) + line_break; | |
var issues = epic[status]; | |
for ( var k = 0; k < issues.length; k ++ ) { | |
epic_reports += issues[k] + line_break; | |
} | |
} | |
epic_reports += line_break + line_break; | |
} | |
console.log( line_break +line_break + line_break + 'GENERAL REPORT' + line_break +line_break + line_break ); | |
console.log( report ); | |
console.log( line_break + line_break+ 'EPIC REPORT' + line_break +line_break + line_break); | |
console.log( epic_reports ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment