@@ -24,7 +24,6 @@ export const compactSoftDeletedTodos = onSchedule({
2424 while ( true ) {
2525 let query = admin . firestore ( )
2626 . collectionGroup ( "todoLists" )
27- . where ( "compactedAt" , "==" , null )
2827 . where ( "deletedAt" , "<=" , admin . firestore . Timestamp . fromDate ( cutoff ) )
2928 . orderBy ( "deletedAt" )
3029 . orderBy ( admin . firestore . FieldPath . documentId ( ) )
@@ -38,6 +37,9 @@ export const compactSoftDeletedTodos = onSchedule({
3837
3938 const batch = admin . firestore ( ) . batch ( ) ;
4039 snapshot . docs . forEach ( ( document ) => {
40+ if ( document . data ( ) ?. compactedAt ) {
41+ return ;
42+ }
4143 batch . update ( document . ref , {
4244 compactedAt : admin . firestore . FieldValue . serverTimestamp ( ) ,
4345 content : admin . firestore . FieldValue . delete ( ) ,
@@ -61,7 +63,7 @@ export const compactSoftDeletedTodos = onSchedule({
6163 toError ( error ) ,
6264 {
6365 collectionGroup : "todoLists" ,
64- filter : `compactedAt == null && deletedAt <= now - ${ TOMBSTONE_GRACE_PERIOD_HOURS } h` ,
66+ filter : `deletedAt <= now - ${ TOMBSTONE_GRACE_PERIOD_HOURS } h` ,
6567 orderBy : [ "deletedAt" , "documentId" ] ,
6668 cleanupBatchSize : CLEANUP_BATCH_SIZE
6769 }
0 commit comments