Skip to content

Commit

Permalink
Fix: first build has started_at = null
Browse files Browse the repository at this point in the history
  • Loading branch information
niktekusho committed Jul 10, 2017
1 parent 67c64a6 commit 919282c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/travis-builds-reporter-core/src/builds-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ module.exports = {
// key will be date only (YYYY-MM-DD), value will be array of builds with that started_at date
const dateKeysMap = new Map();
let build;
const filterFunc = entry => (
extractDateOnly(entry.started_at) === extractDateOnly(build.started_at)
);
const filterFunc = (entry) => {
// pick one that hopefully isn't null
const entryDate = entry.started_at || entry.finished_at;
const buildDate = build.started_at || build.finished_at;
return extractDateOnly(entryDate) === extractDateOnly(buildDate);
};
for (let i = 0; i < builds.length; i += 1) {
build = builds[i];
const buildDateTime = extractDateOnly(build.started_at);
const buildDateTime = extractDateOnly(build.started_at || build.finished_at);
// if the key is present, its return value will be != null and we can skip insertion in map
if (dateKeysMap.get(buildDateTime) == null) {
dateKeysMap.set(buildDateTime, builds.filter(filterFunc));
Expand Down
2 changes: 1 addition & 1 deletion packages/travis-builds-reporter-core/test/builds.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
"pull_request_number": null,
"config": [],
"state": "passed",
"started_at": "2017-03-28T07:23:38Z",
"started_at": null,
"finished_at": "2017-03-28T07:25:44Z",
"duration": 126,
"job_ids": []
Expand Down

0 comments on commit 919282c

Please sign in to comment.