fix user rating refresh if a user is unavailable

If a user's ratings cannot be accessed, e.g. due to network errors, it
should skip to the next user.
Ideally we could mark a user as inactive after X failed retries.
This commit is contained in:
ducklet 2021-11-02 14:14:32 +01:00
parent 52c08f0fd8
commit dd3d5f3670

View file

@ -44,6 +44,7 @@ async def refresh_user_ratings_from_imdb(stop_on_dupe=True):
log.info("⚡️ Loading data for %s ...", user.name) log.info("⚡️ Loading data for %s ...", user.name)
try:
async for rating, is_updated in load_ratings(user.imdb_id): async for rating, is_updated in load_ratings(user.imdb_id):
assert rating.user.id == user.id assert rating.user.id == user.id
@ -52,6 +53,9 @@ async def refresh_user_ratings_from_imdb(stop_on_dupe=True):
yield rating yield rating
except BaseException as err:
log.error("❌ Could not load rating for %s!", user.name, exc_info=err)
def user_ratings_url(user_id): def user_ratings_url(user_id):
return f"https://www.imdb.com/user/{user_id}/ratings" return f"https://www.imdb.com/user/{user_id}/ratings"