Skip to content

Commit 205aaa3

Browse files
committed
fix(cleanup): apply filter when looking for outdated entries
1 parent 80d853f commit 205aaa3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/loader/cleanup-entries.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,21 @@ export async function cleanupEntries(
3232

3333
// Fetch all ids of the collection
3434
do {
35+
// Build search parameters
36+
const searchParams = new URLSearchParams({
37+
page: `${++page}`,
38+
perPage: "1000",
39+
fields: "id"
40+
});
41+
42+
if (options.filter) {
43+
// If a filter is set, add it to the search parameters
44+
searchParams.set("filter", `(${options.filter})`);
45+
}
46+
3547
// Fetch ids from the collection
3648
const collectionRequest = await fetch(
37-
`${collectionUrl}?page=${++page}&perPage=1000&fields=id`,
49+
`${collectionUrl}?${searchParams.toString()}`,
3850
{
3951
headers: collectionHeaders
4052
}

0 commit comments

Comments
 (0)