Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
feat(functions): #1579 added createdAt in build times in database
Browse files Browse the repository at this point in the history
  • Loading branch information
webkhushboo committed Nov 3, 2019
1 parent f344c41 commit 8ee2285
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
11 changes: 7 additions & 4 deletions functions/src/mappers/github/status.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { firestore } from 'firebase-admin';

export interface BuildTimes {
context: string;
time: number;
createdAt: firestore.Timestamp;
}

export interface GitHubPullRequestStatusInput {
Expand All @@ -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 {
Expand All @@ -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)),
};
}
}
6 changes: 3 additions & 3 deletions functions/src/repository/pull-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@
</ng-container>

<ng-container matColumnDef="time">
<th mat-header-cell *matHeaderCellDef>Time</th>
<th mat-header-cell *matHeaderCellDef>Duration</th>
<td mat-cell *matCellDef="let element"> {{ element.buildTimes[0].time }} seconds </td>
</ng-container>

<ng-container matColumnDef="createdAt">
<th mat-header-cell *matHeaderCellDef>Created</th>
<td mat-cell *matCellDef="let element"> {{ element.buildTimes[0].createdAt.toDate() | timeAgo}} </td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
1 change: 1 addition & 0 deletions web/src/app/shared/models/build-times.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class BuildTimes {
context: string;
time: number;
createdAt: Date;
}

0 comments on commit 8ee2285

Please sign in to comment.