mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
extracted filtering part to method
This commit is contained in:
parent
ff32d0ee4a
commit
dffa28f268
1 changed files with 21 additions and 0 deletions
|
|
@ -47,6 +47,27 @@ class ThumbnailEvents(BaseEvent):
|
|||
except Exception:
|
||||
session.rollback()
|
||||
|
||||
def filter_entities(self, event):
|
||||
filtered_entities_info = {}
|
||||
for entity_info in event["data"].get("entities", []):
|
||||
action = entity_info.get("action")
|
||||
if not action:
|
||||
continue
|
||||
|
||||
if (
|
||||
action == "remove"
|
||||
or entity_info["entityType"].lower() != "assetversion"
|
||||
or "thumbid" not in (entity_info.get("keys") or [])
|
||||
):
|
||||
continue
|
||||
|
||||
# Get project id from entity info
|
||||
project_id = entity_info["parents"][-1]["entityId"]
|
||||
if project_id not in filtered_entities_info:
|
||||
filtered_entities_info[project_id] = []
|
||||
filtered_entities_info[project_id].append(entity_info)
|
||||
return filtered_entities_info
|
||||
|
||||
|
||||
def register(session, plugins_presets):
|
||||
ThumbnailEvents(session, plugins_presets).register()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue