parseJobs = runs => {
if(!runs) return undefined;
const retries = [];
return runs.flatMap(run => (run.jobs || []).map(j => {
const name = j.name;
const { run_number } = run;
const retry = retries[[run_number, name]] = (retries[[run_number, name]] || 0) + 1;
const started_at = new Date(j.started_at);
const completed_at = new Date(j.completed_at);
return {
...j,
name,
run,
run_number: `${run_number}.${retry}`,
message: run.head_commit.message,
author: run.head_commit.author.name,
branch: run.head_branch,
started_at,
completed_at,
minutes: (j.completed_at && j.started_at)
? (completed_at - started_at) / 1000 / 60
: undefined
}
}))
}