Permalink
Browse files

feat(): calculated time of previous build

  • Loading branch information...
Izak88 authored and jkuri committed Aug 3, 2017
1 parent d6157ad commit abc7cec3cf5d449b25c181b376da24499f04552e
Showing with 21 additions and 2 deletions.
  1. +17 −1 src/api/db/build.ts
  2. +4 −1 src/app/components/app-build-details/app-build-details.component.ts
@@ -36,7 +36,23 @@ export function getBuild(id: number): Promise<any> {
return job;
});

resolve(build);
return build;
})
.then(build => {
new Build()
.query(q => {
q.where('head_github_id', build.head_github_id)
.andWhere('id', '<', build.id)
.andWhere('start_time', 'is not null')
.andWhere('end_time', 'is not null')
.orderBy('id', 'desc');
})
.fetch()
.then(lastBuild => {
build.lastBuild = lastBuild;

resolve(build);
});
});
});
}
@@ -2,7 +2,7 @@ import { Component, OnInit, NgZone } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ApiService } from '../../services/api.service';
import { SocketService } from '../../services/socket.service';
import { distanceInWordsToNow, format } from 'date-fns';
import { distanceInWordsToNow, distanceInWordsStrict, format } from 'date-fns';

@Component({
selector: 'app-build-details',
@@ -15,6 +15,7 @@ export class AppBuildDetailsComponent implements OnInit {
status: string;
timeWords: string;
totalTime: string;
previousRuntime: string;
processingBuild: boolean;

constructor(
@@ -37,6 +38,8 @@ export class AppBuildDetailsComponent implements OnInit {
this.build = build;
this.build.jobs.forEach(job => job.time = '00:00');
this.timeWords = distanceInWordsToNow(this.build.start_time);
this.previousRuntime = distanceInWordsStrict(
this.build.lastBuild.end_time, this.build.lastBuild.start_time);

this.status = this.getBuildStatus();

0 comments on commit abc7cec

Please sign in to comment.