remove sconds when displaying duration

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-01-25 16:05:17 +01:00
parent 55baa44d2e
commit 20ac4cf8cd
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
4 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "github-comment-manager",
"version": "0.0.1",
"version": "0.1.0",
"description": "Minimal API for managing GitHub comments for CIclicks.",
"repository": "https://github.com/status-im/github-comment-manager",
"main": "index.js",

View File

@ -23,6 +23,11 @@ const dateHelper = (data) => {
)
}
/* remove seconds from duration to make columns equal width */
const shortenDuration = (data) => {
return data.replace(/ [0-9]+ sec$/, '')
}
/* adds archive attribute to builds to mark for folding in template */
const extractArchiveBuilds = (builds) => {
/* get unique commits */
@ -46,6 +51,8 @@ class Comments {
this.owner = owner /* name of user who makes the comments */
/* add helper for formatting dates */
Handlebars.registerHelper('date', dateHelper)
/* add helper for shortening duration field */
Handlebars.registerHelper('shortenDuration', shortenDuration)
/* add helper for checking change in commit */
Handlebars.registerHelper('commitChanged', commitHelper)
/* add partis */

View File

@ -22,9 +22,9 @@ const buildsTable = `
`.trim()
const buildRow = `
{{#if this.success}}
| :heavy_check_mark: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ this.duration }} | \`{{ this.platform }}\` | [:package: package]({{ this.pkg_url }}) |
| :heavy_check_mark: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ shortenDuration this.duration }} | \`{{ this.platform }}\` | [:package: package]({{ this.pkg_url }}) |
{{else}}
| :x: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ this.duration }} | \`{{ this.platform }}\` | [:page_facing_up: build log]({{ this.url }}consoleText) |
| :x: | {{ this.commit }} | [{{ this.id }}]({{ this.url }}) | {{date this.meta.created }} | {{ shortenDuration this.duration }} | \`{{ this.platform }}\` | [:page_facing_up: build log]({{ this.url }}consoleText) |
{{/if}}
`.trim()
module.exports = { main, partials: {buildRow, buildsTable} }

View File

@ -14,7 +14,7 @@ const getBuild = (idx) => ({
commit: `COMMIT-${Math.floor(idx/4)}`,
success: (idx%3) ? true : false,
platform: `PLATFORM-${idx}`,
duration: `DURATION-${idx}`,
duration: `DURATION-${idx} 12 sec`,
url: `URL-${idx}`,
pkg_url: `PKG_URL-${idx}`,
meta: { created: 1545294300000+(idx*56789) },