@@ -31,7 +31,15 @@ export interface EnhancedExecutionSnapshot extends TaskRunExecutionSnapshot {
3131type ExecutionSnapshotWithCheckAndWaitpoints = Prisma . TaskRunExecutionSnapshotGetPayload < {
3232 include : {
3333 checkpoint : true ;
34- completedWaitpoints : true ;
34+ completedWaitpoints : {
35+ include : {
36+ completedByTaskRun : {
37+ select : {
38+ taskIdentifier : true ;
39+ } ;
40+ } ;
41+ } ;
42+ } ;
3543 } ;
3644} > ;
3745
@@ -57,7 +65,9 @@ function enhanceExecutionSnapshot(
5765 */
5866function enhanceExecutionSnapshotWithWaitpoints (
5967 snapshot : ExecutionSnapshotWithCheckpoint ,
60- waitpoints : Waitpoint [ ] ,
68+ waitpoints : ( Waitpoint & {
69+ completedByTaskRun : { taskIdentifier : string | null } | null ;
70+ } ) [ ] ,
6171 completedWaitpointOrder : string [ ]
6272) : EnhancedExecutionSnapshot {
6373 return {
@@ -89,22 +99,23 @@ function enhanceExecutionSnapshotWithWaitpoints(
8999 w . userProvidedIdempotencyKey && ! w . inactiveIdempotencyKey ? w . idempotencyKey : undefined ,
90100 completedByTaskRun : w . completedByTaskRunId
91101 ? {
92- id : w . completedByTaskRunId ,
93- friendlyId : RunId . toFriendlyId ( w . completedByTaskRunId ) ,
94- batch : snapshot . batchId
95- ? {
96- id : snapshot . batchId ,
97- friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
98- }
99- : undefined ,
100- }
102+ id : w . completedByTaskRunId ,
103+ friendlyId : RunId . toFriendlyId ( w . completedByTaskRunId ) ,
104+ batch : snapshot . batchId
105+ ? {
106+ id : snapshot . batchId ,
107+ friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
108+ }
109+ : undefined ,
110+ taskIdentifier : w . completedByTaskRun ?. taskIdentifier ?? undefined ,
111+ }
101112 : undefined ,
102113 completedAfter : w . completedAfter ?? undefined ,
103114 completedByBatch : w . completedByBatchId
104115 ? {
105- id : w . completedByBatchId ,
106- friendlyId : BatchId . toFriendlyId ( w . completedByBatchId ) ,
107- }
116+ id : w . completedByBatchId ,
117+ friendlyId : BatchId . toFriendlyId ( w . completedByBatchId ) ,
118+ }
108119 : undefined ,
109120 output : w . output ?? undefined ,
110121 outputType : w . outputType ,
@@ -137,14 +148,23 @@ async function getSnapshotWaitpointIds(
137148async function fetchWaitpointsInChunks (
138149 prisma : PrismaClientOrTransaction ,
139150 waitpointIds : string [ ]
140- ) : Promise < Waitpoint [ ] > {
151+ ) : Promise < ( Waitpoint & { completedByTaskRun : { taskIdentifier : string | null } | null } ) [ ] > {
141152 if ( waitpointIds . length === 0 ) return [ ] ;
142153
143- const allWaitpoints : Waitpoint [ ] = [ ] ;
154+ const allWaitpoints : ( Waitpoint & {
155+ completedByTaskRun : { taskIdentifier : string | null } | null ;
156+ } ) [ ] = [ ] ;
144157 for ( let i = 0 ; i < waitpointIds . length ; i += WAITPOINT_CHUNK_SIZE ) {
145158 const chunk = waitpointIds . slice ( i , i + WAITPOINT_CHUNK_SIZE ) ;
146159 const waitpoints = await prisma . waitpoint . findMany ( {
147160 where : { id : { in : chunk } } ,
161+ include : {
162+ completedByTaskRun : {
163+ select : {
164+ taskIdentifier : true ,
165+ } ,
166+ } ,
167+ } ,
148168 } ) ;
149169 allWaitpoints . push ( ...waitpoints ) ;
150170 }
@@ -159,7 +179,15 @@ export async function getLatestExecutionSnapshot(
159179 const snapshot = await prisma . taskRunExecutionSnapshot . findFirst ( {
160180 where : { runId, isValid : true } ,
161181 include : {
162- completedWaitpoints : true ,
182+ completedWaitpoints : {
183+ include : {
184+ completedByTaskRun : {
185+ select : {
186+ taskIdentifier : true ,
187+ } ,
188+ } ,
189+ } ,
190+ } ,
163191 checkpoint : true ,
164192 } ,
165193 orderBy : { createdAt : "desc" } ,
@@ -179,7 +207,15 @@ export async function getExecutionSnapshotCompletedWaitpoints(
179207 const waitpoints = await prisma . taskRunExecutionSnapshot . findFirst ( {
180208 where : { id : snapshotId } ,
181209 include : {
182- completedWaitpoints : true ,
210+ completedWaitpoints : {
211+ include : {
212+ completedByTaskRun : {
213+ select : {
214+ taskIdentifier : true ,
215+ } ,
216+ } ,
217+ } ,
218+ } ,
183219 } ,
184220 } ) ;
185221
@@ -233,19 +269,19 @@ export function executionDataFromSnapshot(snapshot: EnhancedExecutionSnapshot):
233269 } ,
234270 batch : snapshot . batchId
235271 ? {
236- id : snapshot . batchId ,
237- friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
238- }
272+ id : snapshot . batchId ,
273+ friendlyId : BatchId . toFriendlyId ( snapshot . batchId ) ,
274+ }
239275 : undefined ,
240276 checkpoint : snapshot . checkpoint
241277 ? {
242- id : snapshot . checkpoint . id ,
243- friendlyId : snapshot . checkpoint . friendlyId ,
244- type : snapshot . checkpoint . type ,
245- location : snapshot . checkpoint . location ,
246- imageRef : snapshot . checkpoint . imageRef ,
247- reason : snapshot . checkpoint . reason ?? undefined ,
248- }
278+ id : snapshot . checkpoint . id ,
279+ friendlyId : snapshot . checkpoint . friendlyId ,
280+ type : snapshot . checkpoint . type ,
281+ location : snapshot . checkpoint . location ,
282+ imageRef : snapshot . checkpoint . imageRef ,
283+ reason : snapshot . checkpoint . reason ?? undefined ,
284+ }
249285 : undefined ,
250286 completedWaitpoints : snapshot . completedWaitpoints ,
251287 } ;
0 commit comments