change timeout periods to never allow more than once per minute

This commit is contained in:
nanos 2024-06-25 10:54:00 +01:00
parent de656d1e0d
commit ac2b648e05

View file

@ -478,13 +478,13 @@ def toot_context_should_be_fetched(toot):
lastSeenInSeconds = (datetime.now(lastSeen.tzinfo) - lastSeen).total_seconds() lastSeenInSeconds = (datetime.now(lastSeen.tzinfo) - lastSeen).total_seconds()
ageInSeconds = (datetime.now(createdAt.tzinfo) - createdAt).total_seconds() ageInSeconds = (datetime.now(createdAt.tzinfo) - createdAt).total_seconds()
if(ageInSeconds <= 60 * 60): if(ageInSeconds <= 60 * 60 and lastSeenInSeconds >= 60):
# For the first hour: allow refetching context as desired # For the first hour: allow refetching once per minute
return True return True
if(ageInSeconds <= 24 * 60 * 60 and lastSeenInSeconds > 10 * 60): if(ageInSeconds <= 24 * 60 * 60 and lastSeenInSeconds >= 10 * 60):
# For the next day: once every 10 minutes # For the rest of the first day: once every 10 minutes
return True return True
if(lastSeenInSeconds > 60 * 60): if(lastSeenInSeconds >= 60 * 60):
# After that: hourly # After that: hourly
return True return True
return False return False