From 404f9f09281c86e5d20fdb07855eeb9b913bbdb9 Mon Sep 17 00:00:00 2001 From: lluni Date: Thu, 3 Aug 2023 00:24:28 +0200 Subject: [PATCH] Improved logging --- cleanup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cleanup.py b/cleanup.py index bd94b69..ff7574a 100644 --- a/cleanup.py +++ b/cleanup.py @@ -40,19 +40,20 @@ def cleanup(offset: int = 200, limit: int = 40, id: int | None = None): iterations = offset // 40 remainder = offset % 40 # get latest posts until offset is reached - for _ in range(iterations): + for i in range(iterations): last_posts = get_account_statuses(max_id=id_oldest_of_last_posts, limit=40) if len(last_posts) == 0: print("Offset is higher than the number of posts in the past.") return id_oldest_of_last_posts = last_posts[-1]["id"] - print("Last post:", last_posts[-1]["url"]) + print(f"Currently at offset {(i + 1) * 40}, last ignored post: {last_posts[-1]['url']}") if remainder != 0: last_posts = get_account_statuses(max_id=id_oldest_of_last_posts, limit=remainder) if len(last_posts) == 0: print("Offset is higher than the number of posts in the past.") return id_oldest_of_last_posts = last_posts[-1]["id"] + print(f"Currently at offset {iterations * 40 + remainder}, last ignored post: {last_posts[-1]['url']}") else: id_oldest_of_last_posts = id last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, max_id=id, limit=limit)