Skip to content

Commit

Permalink
ENH: Avoid duplicating attributes stored in table
Browse files Browse the repository at this point in the history
  • Loading branch information
cortadocodes committed Apr 10, 2024
1 parent 3482a14 commit 57bce74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
17 changes: 8 additions & 9 deletions functions/event_handler/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ def store_pub_sub_event_in_bigquery(cloud_event):

row = {
"event": event,
"attributes": attributes,
"other_attributes": attributes,
# Pull out some attributes into columns for querying.
"uuid": attributes["uuid"],
"originator": attributes["originator"],
"sender": attributes["sender"],
"sender_type": attributes["sender_type"],
"sender_sdk_version": attributes["sender_sdk_version"],
"recipient": attributes["recipient"],
"question_uuid": attributes["question_uuid"],
"order": attributes["order"],
"originator": attributes.pop("originator"),
"sender": attributes.pop("sender"),
"sender_type": attributes.pop("sender_type"),
"sender_sdk_version": attributes.pop("sender_sdk_version"),
"recipient": attributes.pop("recipient"),
"question_uuid": attributes.pop("question_uuid"),
"order": attributes.pop("order"),
# Backend-specific metadata.
"backend": BACKEND,
"backend_metadata": backend_metadata,
Expand Down
10 changes: 1 addition & 9 deletions tests/test_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,9 @@ def test_store_pub_sub_event_in_bigquery(self):
mock_big_query_client.inserted_rows[0][0],
{
"event": "some-data",
"attributes": {
"other_attributes": {
"uuid": "c8bda9fa-f072-4330-92b1-96920d06b28d",
"originator": "octue/test-service:5.6.3",
"sender": "octue/test-service:5.6.3",
"sender_type": "PARENT",
"sender_sdk_version": "1.0.3",
"recipient": "octue/another-service:1.0.0",
"question_uuid": "ca534cdd-24cb-4ed2-af57-e36757192acb",
"order": "0",
},
"uuid": "c8bda9fa-f072-4330-92b1-96920d06b28d",
"originator": "octue/test-service:5.6.3",
"sender": "octue/test-service:5.6.3",
"sender_type": "PARENT",
Expand Down

0 comments on commit 57bce74

Please sign in to comment.