Skip to content

Commit

Permalink
max_id from incoming vs parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all committed Nov 14, 2023
1 parent 4656e6f commit 8771593
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/jobs/kafka/players/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ def is_today(updated_at: str):
return date == today


async def parse_data(players: list[dict]):
async def parse_data(players: list[dict]) -> tuple[list[Player], int]:
players: list[Player] = [Player(**player) for player in players]
max_id = max([p.id for p in players])
players = [
player
for player in players
if len(player.name) < 13 and is_today(player.updated_at)
]
return players
return players, max_id


async def get_request(
Expand Down Expand Up @@ -111,13 +112,17 @@ async def get_data(receive_queue: Queue):
await asyncio.sleep(sleep_time)
continue

players = await parse_data(players=players)
logger.info({"received": len(players), "max_id": {params.get("player_id")}})
players, max_id = await parse_data(players=players)
logger.info(
{
"received": len_players,
"parsed": len(players),
"max_id": {params.get("player_id")},
}
)

await asyncio.gather(*[receive_queue.put(item=p) for p in players])

max_id = max([p.id for p in players])

if max_id > params["player_id"]:
params["player_id"] = max_id

Expand Down

0 comments on commit 8771593

Please sign in to comment.