Skip to content

Commit 45eb971

Browse files
committed
chore: final changes to remove stale workflow file
1 parent 8fdfb86 commit 45eb971

File tree

1 file changed

+3
-42
lines changed

1 file changed

+3
-42
lines changed

script/remove-stale.js

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ async function processBucket(bucket) {
1111
let cursor = null;
1212
let batch = 0;
1313
let truncated = true;
14-
const allRemovedItems = [];
15-
while (truncated && allRemovedItems.length < 10000) {
14+
while (truncated) {
1615
const body = {
1716
bucket,
1817
cursor,
@@ -34,59 +33,21 @@ async function processBucket(bucket) {
3433
}
3534

3635
const json = await res.json();
37-
const toAdd = json.removedItems.slice(0, 10000 - allRemovedItems.length);
38-
allRemovedItems.push(...toAdd);
39-
4036
console.log(`[${bucket}] Batch ${batch} - Removed items:`, json.removedItems.length);
4137
cursor = json.cursor;
4238
truncated = json.truncated;
4339
batch++;
44-
if (!truncated || allRemovedItems.length >= 10000) {
40+
if (!truncated) {
4541
console.log(`[${bucket}] Completed. Total batches: ${batch}`);
4642
}
4743
} catch (e) {
4844
console.error(`[${bucket}] Batch ${batch} - Request failed:`, e);
4945
process.exit(1);
5046
}
5147
}
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-
}
8848
}
8949

50+
9051
(async () => {
9152
// for (const bucket of ['packages', 'templates']) {
9253
for (const bucket of ['packages']) {

0 commit comments

Comments
 (0)