File tree Expand file tree Collapse file tree
src/routes/(api)/job/[jobId=idNumber]/build/[buildId=idNumber] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -145,6 +145,13 @@ export const DELETE: RequestHandler = async ({ params }) => {
145145 id : true ,
146146 app_id : true
147147 }
148+ } ,
149+ release : {
150+ select : {
151+ id : true ,
152+ build_guid : true ,
153+ status : true
154+ }
148155 }
149156 }
150157 } ) ;
@@ -153,6 +160,11 @@ export const DELETE: RequestHandler = async ({ params }) => {
153160
154161 await prisma . build . delete ( { where : { id : build . id } } ) ;
155162
163+ await prisma . $transaction ( [
164+ prisma . release . deleteMany ( { where : { build : { id : build . id } } } ) ,
165+ prisma . build . deleteMany ( { where : { id : build . id } } )
166+ ] ) ;
167+
156168 if ( build . build_guid && build . status !== Build . Status . Completed ) {
157169 await getQueues ( ) . Builds . add ( `Cancel Build #${ build . id } ` , {
158170 type : BullMQ . JobType . Build_Cancel ,
@@ -161,5 +173,15 @@ export const DELETE: RequestHandler = async ({ params }) => {
161173 } ) ;
162174 }
163175
176+ for ( const release of build . release ) {
177+ if ( release . build_guid && release . status !== Release . Status . Completed ) {
178+ await getQueues ( ) . Releases . add ( `Cancel Release #${ release . id } ` , {
179+ type : BullMQ . JobType . Release_Cancel ,
180+ guid : release . build_guid ,
181+ release : { ...release , build }
182+ } ) ;
183+ }
184+ }
185+
164186 return new Response ( JSON . stringify ( { } ) ) ;
165187} ;
You can’t perform that action at this time.
0 commit comments