Skip to content

Commit

Permalink
show unfiltered post collect count
Browse files Browse the repository at this point in the history
  • Loading branch information
marcustyphoon committed Aug 28, 2024
1 parent f2c5f1d commit 4162b23
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/features/mass_deleter.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,22 @@ const deleteDrafts = async function ({ blogName, before }) {
]
});

const allDrafts = [];
const drafts = [];
let resource = `/v2/blog/${blogName}/posts/draft?limit=50`;

while (resource) {
await Promise.all([
apiFetch(resource).then(({ response }) => {
const posts = response.posts
.filter(({ canEdit }) => canEdit === true)
.filter(({ timestamp }) => timestamp < before);
.filter(({ canEdit }) => canEdit === true);

allDrafts.push(...posts);
drafts.push(...posts.filter(({ timestamp }) => timestamp < before));

drafts.push(...posts);
resource = response.links?.next?.href;

foundPostsElement.textContent = `Found ${drafts.length} drafts${resource ? '...' : '.'}`;
foundPostsElement.textContent = `Found ${drafts.length} drafts (checked ${allDrafts.length})${resource ? '...' : '.'}`;
}),
sleep(1000)
]);
Expand Down

0 comments on commit 4162b23

Please sign in to comment.