Skip to content

Commit

Permalink
TaskRun.startedAt will now be lazily migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
ericallam committed Jun 18, 2024
1 parent 1b90ffb commit 233316f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class ApiRetrieveRunPresenter extends BasePresenter {
version: taskRun.lockedToVersion ? taskRun.lockedToVersion.version : undefined,
createdAt: taskRun.createdAt ?? undefined,
updatedAt: taskRun.updatedAt ?? undefined,
startedAt: taskRun.startedAt ?? undefined,
startedAt: taskRun.startedAt ?? taskRun.lockedAt ?? undefined,
finishedAt: ApiRetrieveRunPresenter.isStatusFinished(apiStatus)
? taskRun.updatedAt
: undefined,
Expand Down
6 changes: 5 additions & 1 deletion apps/webapp/app/presenters/v3/RunListPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export class RunListPresenter extends BasePresenter {
status: TaskRunStatus;
createdAt: Date;
startedAt: Date | null;
lockedAt: Date | null;
updatedAt: Date;
isTest: boolean;
spanId: string;
Expand All @@ -173,6 +174,7 @@ export class RunListPresenter extends BasePresenter {
tr.status AS status,
tr."createdAt" AS "createdAt",
tr."startedAt" AS "startedAt",
tr."lockedAt" AS "lockedAt",
tr."updatedAt" AS "updatedAt",
tr."isTest" AS "isTest",
tr."spanId" AS "spanId",
Expand Down Expand Up @@ -272,13 +274,15 @@ export class RunListPresenter extends BasePresenter {

const hasFinished = FINISHED_STATUSES.includes(run.status);

const startedAt = run.startedAt ?? run.lockedAt;

return {
id: run.id,
friendlyId: run.runFriendlyId,
number: Number(run.number),
createdAt: run.createdAt.toISOString(),
updatedAt: run.updatedAt.toISOString(),
startedAt: run.startedAt ? run.startedAt.toISOString() : undefined,
startedAt: startedAt ? startedAt.toISOString() : undefined,
hasFinished,
finishedAt: hasFinished ? run.updatedAt.toISOString() : undefined,
isTest: run.isTest,
Expand Down
2 changes: 1 addition & 1 deletion apps/webapp/app/presenters/v3/TaskListPresenter.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class TaskListPresenter extends BasePresenter {
>`
SELECT
tr."taskIdentifier",
AVG(EXTRACT(EPOCH FROM (tr."updatedAt" - tr."startedAt"))) as duration
AVG(EXTRACT(EPOCH FROM (tr."updatedAt" - COALESCE(tr."startedAt", tr."lockedAt")))) as duration
FROM
${sqlDatabaseSchema}."TaskRun" as tr
WHERE
Expand Down

0 comments on commit 233316f

Please sign in to comment.