From 1c890fe7c7df76e0147d2d867f76cbafe2ec37a5 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Wed, 8 Jan 2025 11:07:04 +0100 Subject: [PATCH] avoid using `id` --- server/planning/events/events.py | 16 +++++++--------- server/planning/events/events_history.py | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/server/planning/events/events.py b/server/planning/events/events.py index c2ee484c0..62d1d4ddd 100644 --- a/server/planning/events/events.py +++ b/server/planning/events/events.py @@ -138,17 +138,15 @@ def is_event_updated(new_item: Event, old_item: Event) -> bool: return False -def get_user_updated_keys(id: str) -> set[str]: - # Placeholder function definition - # Replace this with the actual implementation +def get_user_updated_keys(event_id: str) -> set[str]: history_service = get_resource_service("events_history") - updates = history_service.get_by_id(id) + updates = history_service.get_by_id(event_id) updated_keys = set() for update in updates: if not update.get("user_id"): continue - for key in update.get("update", {}): - updated_keys.add(key) + if update.get("update"): + updated_keys.update(update["update"].keys()) return updated_keys @@ -168,17 +166,17 @@ def post_in_mongo(self, docs, **kwargs): self.on_created(docs) return ids - def patch_in_mongo(self, id: str, document, original) -> Optional[Dict[str, Any]]: + def patch_in_mongo(self, _id: str, document, original) -> Optional[Dict[str, Any]]: """Patch an ingested item onto an existing item locally""" content_fields = app.config.get("EVENT_INGEST_CONTENT_FIELDS", CONTENT_FIELDS) - updated_keys = get_user_updated_keys(id) + updated_keys = get_user_updated_keys(_id) for key in updated_keys: if key in document and key in content_fields and original.get(key): document[key] = original[key] set_planning_schedule(document) update_ingest_on_patch(document, original) - response = self.backend.update_in_mongo(self.datasource, id, document, original) + response = self.backend.update_in_mongo(self.datasource, _id, document, original) self.on_updated(document, original, from_ingest=True) return response diff --git a/server/planning/events/events_history.py b/server/planning/events/events_history.py index 2017acaa1..34db104b4 100644 --- a/server/planning/events/events_history.py +++ b/server/planning/events/events_history.py @@ -99,8 +99,8 @@ def on_update_repetitions(self, updates, event_id, operation): def on_update_time(self, updates, original): self.on_item_updated(updates, original, "update_time") - def get_by_id(self, id: str) -> list[EventHistoryRecord]: - records = self.find(where={"event_id": id}) + def get_by_id(self, _id: str) -> list[EventHistoryRecord]: + records = self.find(where={"event_id": _id}) return [ { "event_id": record.get("event_id"),