Skip to content

Commit

Permalink
tweaked stats update script
Browse files Browse the repository at this point in the history
  • Loading branch information
victorverma3 committed Jan 22, 2025
1 parent c723308 commit 139b6bb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions backend/data_processing/update_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,15 @@ async def statistics_update():
raise e

# gets all updated user statistics
tasks = [
process_user_statistics_update(user, movie_data) for user in statistics_users
batch_size = 20
batches = [
statistics_users[i : i + batch_size]
for i in range(0, len(statistics_users), batch_size)
]
results = await asyncio.gather(*tasks)
results = []
for batch in batches:
tasks = [process_user_statistics_update(user, movie_data) for user in batch]
results.extend(await asyncio.gather(*tasks))
all_stats = {user: stats for user, stats in results if stats is not None}

# updates user statistics in database
Expand Down

0 comments on commit 139b6bb

Please sign in to comment.