@@ -11,7 +11,8 @@ async function processBucket(bucket) {
1111 let cursor = null ;
1212 let batch = 0 ;
1313 let truncated = true ;
14- while ( truncated ) {
14+ const allRemovedItems = [ ] ;
15+ while ( truncated && allRemovedItems . length < 10000 ) {
1516 const body = {
1617 bucket,
1718 cursor,
@@ -33,19 +34,57 @@ async function processBucket(bucket) {
3334 }
3435
3536 const json = await res . json ( ) ;
37+ const toAdd = json . removedItems . slice ( 0 , 10000 - allRemovedItems . length ) ;
38+ allRemovedItems . push ( ...toAdd ) ;
3639
3740 console . log ( `[${ bucket } ] Batch ${ batch } - Removed items:` , json . removedItems . length ) ;
3841 cursor = json . cursor ;
3942 truncated = json . truncated ;
4043 batch ++ ;
41- if ( ! truncated ) {
44+ if ( ! truncated || allRemovedItems . length >= 10000 ) {
4245 console . log ( `[${ bucket } ] Completed. Total batches: ${ batch } ` ) ;
4346 }
4447 } catch ( e ) {
4548 console . error ( `[${ bucket } ] Batch ${ batch } - Request failed:` , e ) ;
4649 process . exit ( 1 ) ;
4750 }
4851 }
52+
53+ // Verification logic for first 10,000 removed items
54+ const now = Date . now ( ) ;
55+ const sixMonthsAgo = new Date ( now ) ;
56+ sixMonthsAgo . setMonth ( sixMonthsAgo . getMonth ( ) - 6 ) ;
57+ const oneMonthAgo = new Date ( now ) ;
58+ oneMonthAgo . setMonth ( oneMonthAgo . getMonth ( ) - 1 ) ;
59+
60+ let passCount = 0 ;
61+ let failCount = 0 ;
62+ const failedItems = [ ] ;
63+
64+ for ( let i = 0 ; i < allRemovedItems . length ; i ++ ) {
65+ const item = allRemovedItems [ i ] ;
66+ const uploadedDate = new Date ( item . uploaded ) ;
67+ if ( uploadedDate <= sixMonthsAgo ) {
68+ passCount ++ ;
69+ continue ;
70+ }
71+ if ( item . downloadedAt ) {
72+ const downloadedAtDate = new Date ( item . downloadedAt ) ;
73+ if ( downloadedAtDate <= oneMonthAgo && uploadedDate <= oneMonthAgo ) {
74+ passCount ++ ;
75+ continue ;
76+ }
77+ }
78+ failCount ++ ;
79+ failedItems . push ( item ) ;
80+ }
81+
82+ console . log ( `Verification complete for first 10,000 removed items.` ) ;
83+ console . log ( `Passed: ${ passCount } ` ) ;
84+ console . log ( `Failed: ${ failCount } ` ) ;
85+ if ( failCount > 0 ) {
86+ console . log ( `First 5 failed items:` , failedItems . slice ( 0 , 5 ) ) ;
87+ }
4988}
5089
5190( async ( ) => {
0 commit comments