Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
show duration of a build in sparkline
Browse files Browse the repository at this point in the history
  • Loading branch information
leipreachan committed Oct 18, 2019
1 parent a9c5491 commit 3bef50d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions content_scripts/better.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ function draw_sparkline() {
for (let i in testResults) {
const item = testResults[i],
value = item.hasAttribute('status') ? item.attributes.status.nodeValue : '',
duration = item.hasAttribute('duration') ? item.attributes.duration.nodeValue : false,
buildInfo = item.getElementsByTagName('build')[0],
buildTypeName = item.getElementsByTagName('buildType')[0].attributes.name.nodeValue,
rect = attrs(document.createElementNS('http://www.w3.org/2000/svg', 'rect'), {x, width});
Expand All @@ -218,8 +219,18 @@ function draw_sparkline() {
const buildDate = item.getElementsByTagName('startDate')[0].textContent,
buildBranchName = buildInfo.hasAttribute('branchName') ? buildInfo.attributes.branchName.nodeValue : '<empty>',
t = /(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})/.exec(buildDate);
let duration_string = '';
if (duration) {
const mins_dec = duration/60000,
mins = Math.trunc(mins_dec),
sec_dec = (mins_dec - mins) * 60,
sec = Math.trunc(sec_dec),
ms = Math.round((sec_dec - sec)*1000),
sec_padded = (sec+'').padStart(2, '0');
duration_string = `\nduration: ${mins}m:${sec_padded}s,${ms}ms`;
}
rect.titletime = `${t[1]}-${t[2]}-${t[3]} ${t[4]}:${t[5]}:${t[6]}`;
rect.title = `${buildTypeName}\nbranch: ${buildBranchName}`;
rect.title = `${buildTypeName}\nbranch: ${buildBranchName}${duration_string}`;
rect.onmouseover = showPopup;
rect.onmouseout = hidePopup;
svgNode.appendChild(rect);
Expand Down Expand Up @@ -255,7 +266,7 @@ function draw_sparkline() {
}

const
testResultsUrl = `${tcEntryPoint}?fields=testOccurrence(status,build(id,branchName,buildType(name),startDate))&locator=test:${testId},ignored:false,count:${SPARKLINE_POINTS}`;
testResultsUrl = `${tcEntryPoint}?fields=testOccurrence(status,duration,build(id,branchName,buildType(name),startDate))&locator=test:(id:${testId}),ignored:false,count:${SPARKLINE_POINTS}`;

if (this.firstChild) this.removeChild(this.firstChild);

Expand Down Expand Up @@ -584,4 +595,4 @@ function hide_loader() {
debug('stop observing');
})
};
})();
})();
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "View artifacts in teamcity reports",
"manifest_version": 2,
"name": "tc-better-reports",
"version": "0.2.10.0",
"version": "0.2.11.0",
"homepage_url": "http://tech.badoo.com",
"icons": {
"128": "icons/report-128.png"
Expand Down

0 comments on commit 3bef50d

Please sign in to comment.