diff --git a/functions/src/mappers/github/status.mapper.ts b/functions/src/mappers/github/status.mapper.ts index a39578079..08bd91966 100644 --- a/functions/src/mappers/github/status.mapper.ts +++ b/functions/src/mappers/github/status.mapper.ts @@ -1,6 +1,9 @@ +import { firestore } from 'firebase-admin'; + export interface BuildTimes { context: string; time: number; + createdAt: firestore.Timestamp; } export interface GitHubPullRequestStatusInput { @@ -15,8 +18,8 @@ export interface GitHubPullRequestStatusModel { id: number; state: string; context: string; - createdAt: string; - updatedAt: string; + createdAt: firestore.Timestamp; + updatedAt: firestore.Timestamp; } export class GitHubPullRequestStatusMapper { @@ -25,8 +28,8 @@ export class GitHubPullRequestStatusMapper { id: input.id, state: input.state, context: input.context, - createdAt: input.created_at, - updatedAt: input.updated_at, + createdAt: firestore.Timestamp.fromDate(new Date(input.created_at)), + updatedAt: firestore.Timestamp.fromDate(new Date(input.updated_at)), }; } } diff --git a/functions/src/repository/pull-request.ts b/functions/src/repository/pull-request.ts index ec1eed8d6..3582dce70 100644 --- a/functions/src/repository/pull-request.ts +++ b/functions/src/repository/pull-request.ts @@ -18,9 +18,9 @@ export const getPullRequestBuildTime: any = (statuses: GitHubPullRequestStatusMo uniqueContexts.map((context: string) => { const filteredStatus: GitHubPullRequestStatusModel[] = statuses.filter((status: GitHubPullRequestStatusModel) => status.context === context); if (filteredStatus.length > 0) { - const buildTime: number = Math.floor(new Date(filteredStatus[0].updatedAt).getTime() - - new Date(filteredStatus[filteredStatus.length - 1].updatedAt).getTime()) / 1000; - buildTimes.push({ context: context, time: buildTime }); + const buildTime: number = Math.floor((filteredStatus[0].updatedAt.toDate().getTime() + - filteredStatus[filteredStatus.length - 1].updatedAt.toDate().getTime())) / 1000; + buildTimes.push({ context: context, time: buildTime, createdAt: filteredStatus[0].createdAt }); } }); return buildTimes; diff --git a/web/src/app/projects/build-history/build-history.component.html b/web/src/app/projects/build-history/build-history.component.html index b5f43ba23..163fc6161 100644 --- a/web/src/app/projects/build-history/build-history.component.html +++ b/web/src/app/projects/build-history/build-history.component.html @@ -26,10 +26,15 @@ - Time + Duration {{ element.buildTimes[0].time }} seconds + + Created + {{ element.buildTimes[0].createdAt.toDate() | timeAgo}} + + diff --git a/web/src/app/projects/build-history/build-history.component.ts b/web/src/app/projects/build-history/build-history.component.ts index 9f5bc1416..d0f3eac58 100644 --- a/web/src/app/projects/build-history/build-history.component.ts +++ b/web/src/app/projects/build-history/build-history.component.ts @@ -16,7 +16,7 @@ export class BuildHistoryComponent implements OnInit { public repoUid: string; public pullRequestUid: string; public historic: []; - public displayedColumns: string[] = ['commitId', 'time']; + public displayedColumns: string[] = ['commitId', 'time', 'createdAt']; public status: PullRequestStatusModel; /** diff --git a/web/src/app/shared/models/build-times.model.ts b/web/src/app/shared/models/build-times.model.ts index 6c1a69434..3ded8f740 100644 --- a/web/src/app/shared/models/build-times.model.ts +++ b/web/src/app/shared/models/build-times.model.ts @@ -1,4 +1,5 @@ export class BuildTimes { context: string; time: number; + createdAt: Date; }