Skip to content

Commit

Permalink
feat(): calculated time of previous build
Browse files Browse the repository at this point in the history
  • Loading branch information
Izak88 authored and jkuri committed Aug 5, 2017
1 parent d6157ad commit abc7cec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/api/db/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -15,6 +15,7 @@ export class AppBuildDetailsComponent implements OnInit {
status: string;
timeWords: string;
totalTime: string;
previousRuntime: string;
processingBuild: boolean;

constructor(
Expand All @@ -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();

Expand Down

0 comments on commit abc7cec

Please sign in to comment.