Compare commits
No commits in common. "bca10829a5a9a97c58fa18d19eaeb6f961eed1b4" and "70625e5f1b3891873f4633e51a4e9fbc2d665416" have entirely different histories.
bca10829a5
...
70625e5f1b
1 changed files with 4 additions and 8 deletions
12
cleanup.py
12
cleanup.py
|
@ -26,9 +26,6 @@ def cleanup(limit: int = 40, id: int | None = None):
|
|||
last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, limit=limit)
|
||||
id_oldest_of_last_posts = -1
|
||||
for _ in range(4):
|
||||
# return if there are no posts to check
|
||||
if len(last_posts) == 0:
|
||||
return
|
||||
id_oldest_of_last_posts = last_posts[-1]["id"]
|
||||
last_posts = mastodon.account_statuses(getenv("MASTODON_USER_ID"), exclude_replies=True, max_id=id_oldest_of_last_posts, limit=limit)
|
||||
else:
|
||||
|
@ -39,12 +36,11 @@ def cleanup(limit: int = 40, id: int | None = None):
|
|||
if len(last_posts) == 0:
|
||||
return
|
||||
|
||||
# ----- delete old inactive posts ----- #
|
||||
# ----- delete old posts ----- #
|
||||
|
||||
# default: check 10 batches of 40 posts
|
||||
# this usually tries until the rate limit is triggered or there are no more posts
|
||||
# if hitting the rate limit is undesired, reduce the number of iterations
|
||||
for i in range(10):
|
||||
# default: check 2 batches of 40 posts (and 6 batches if the id was set manually)
|
||||
num_batches = 2 if id is None else 6
|
||||
for i in range(num_batches):
|
||||
# skip getting new batch in the first iteration if the id was set manually
|
||||
if i != 0 or id is None:
|
||||
# find id of the currently oldest post
|
||||
|
|
Loading…
Reference in a new issue