Skip to content

Commit

Permalink
fix: do not send duplicated events in batch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Oct 15, 2024
1 parent c650d4a commit 0d8329c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions event_routing_backends/backends/events_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,13 @@ def bulk_send(self, events):
for events_for_route in event_routes.values():
prepared_events = []
host = None
ids = set()
for _, updated_event, host, _ in events_for_route:
if updated_event["id"] in set():
logger.info(f"Found duplicated event {updated_event['id']}")
continue
prepared_events.append(updated_event)
ids.add(updated_event["id"])

if prepared_events: # pragma: no cover
self.dispatch_bulk_events(
Expand Down
2 changes: 1 addition & 1 deletion event_routing_backends/utils/xapi_lrs_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def bulk_send(self, statement_data):
response = self.lrs_client.save_statements(statement_data)

if not response.success:
if response.response.code == 409 or response.response.code == 204:
if response.response.code == 409:
logger.warning(f"Duplicate event id found in: {response.request.content}")
else:
logger.warning(f"Failed request: {response.request.content}")
Expand Down

0 comments on commit 0d8329c

Please sign in to comment.