Skip to content

Commit

Permalink
Revert "Simplify checking for updates"
Browse files Browse the repository at this point in the history
I remembered why that was necessary.

This reverts commit a6e769e.
  • Loading branch information
Electronic-Mango committed Jun 16, 2024
1 parent a6e769e commit 67ba12a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/main/bot/update_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
is handled in separate modules.
"""

from asyncio import sleep
from datetime import datetime
from random import randrange
from time import struct_time
Expand Down Expand Up @@ -43,19 +42,15 @@ async def _delayed_check_for_all_updates(context: ContextTypes.DEFAULT_TYPE) ->
logger.info("Quiet hour, skipping checking for updates")
return
logger.info("Starting checking for all updates")
delay = 0
for feed_data in get_all_stored_data():
await _check_for_updates(context, *feed_data)
await sleep(LOOKUP_FEED_DELAY + randrange(max(LOOKUP_FEED_DELAY_RANDOMNESS, 1)))
context.job_queue.run_once(callback=_check_for_updates, when=delay, data=feed_data)
delay += LOOKUP_FEED_DELAY
delay += randrange(max(LOOKUP_FEED_DELAY_RANDOMNESS, 1)) # randrange(1) always returns 0


async def _check_for_updates(
context: ContextTypes.DEFAULT_TYPE,
chat_id: int,
feed_type: str,
feed_name: str,
id: str,
date: struct_time,
) -> None:
async def _check_for_updates(context: ContextTypes.DEFAULT_TYPE) -> None:
chat_id, feed_type, feed_name, id, date = context.job.data
logger.info(f"[{chat_id}] Checking for updates for [{feed_name}] [{feed_type}]")
feed = get_parsed_feed(feed_type, feed_name)
if feed_is_valid(feed):
Expand Down

0 comments on commit 67ba12a

Please sign in to comment.