@@ -204,12 +204,15 @@ export const scanWebhook = async () => {
204204 const params = [ ] ;
205205 let p = 1 ;
206206 for ( const bd of prepared ) {
207- vals . push ( `($${ p } , $${ p + 1 } , $${ p + 2 } , $${ p + 3 } , $${ p + 4 } , $${ p + 5 } , $${ p + 6 } , $${ p + 7 } )` ) ;
208- params . push ( auditId , JSON . stringify ( [ ] ) , bd . node , bd . contentNormalized , bd . contentHashId , bd . shortId , urlId , effectiveScanId ) ;
209- p += 8 ;
207+ vals . push ( `($${ p } , $${ p + 1 } , $${ p + 2 } , $${ p + 3 } , $${ p + 4 } , $${ p + 5 } , $${ p + 6 } , $${ p + 7 } , $${ p + 8 } )` ) ;
208+ // Snapshot the URL string as `url_text` so it survives URL row deletion
209+ // (e.g., CSV format change removing/replacing URLs). Falls back to NULL
210+ // if the webhook payload didn't include the url.
211+ params . push ( auditId , JSON . stringify ( [ ] ) , bd . node , bd . contentNormalized , bd . contentHashId , bd . shortId , urlId , effectiveScanId , url ?? null ) ;
212+ p += 9 ;
210213 }
211214 const result = await db . query ( {
212- text : `INSERT INTO "blockers" ("audit_id", "targets", "content", "content_normalized", "content_hash_id", "short_id", "url_id", "scan_id") VALUES ${ vals . join ( ', ' ) } RETURNING "id"` ,
215+ text : `INSERT INTO "blockers" ("audit_id", "targets", "content", "content_normalized", "content_hash_id", "short_id", "url_id", "scan_id", "url_text" ) VALUES ${ vals . join ( ', ' ) } RETURNING "id"` ,
213216 values : params ,
214217 } ) ;
215218 blockerIds = result . rows . map ( ( r : any ) => r . id ) ;
0 commit comments