Skip to content

Commit

Permalink
Fixes potential non-existent attribute error in save_collection_value()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Kasaboski committed Nov 26, 2024
1 parent f89fcab commit 91aca4c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/flare/bin/cron_job_ingest_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,13 @@ def save_last_fetched(kvstore: KVStoreCollections) -> None:


def get_collection_value(kvstore: KVStoreCollections, key: str) -> Optional[str]:
if KV_COLLECTION_NAME in kvstore:
data = kvstore[KV_COLLECTION_NAME].data.query()
for entry in data:
if entry["_key"] == key:
return entry["value"]
# Ensure collection exists
create_collection(kvstore=kvstore)

data = kvstore[KV_COLLECTION_NAME].data.query()
for entry in data:
if entry["_key"] == key:
return entry["value"]

return None

Expand All @@ -265,11 +267,12 @@ def save_collection_value(kvstore: KVStoreCollections, key: str, value: Any) ->
}
)
)
else:
kvstore[KV_COLLECTION_NAME].data.update(
id=key,
data=json.dumps({"value": value}),
)
return

kvstore[KV_COLLECTION_NAME].data.update(
id=key,
data=json.dumps({"value": value}),
)


def fetch_feed(
Expand Down

0 comments on commit 91aca4c

Please sign in to comment.