From f6623787b17ad1737544d8c32df27df2f6d72f1a Mon Sep 17 00:00:00 2001 From: Martastain Date: Fri, 15 Nov 2024 13:15:53 +0100 Subject: [PATCH] feat: add changedBefore and changedAfter args for activities graphql resolver --- ayon_server/graphql/resolvers/activities.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ayon_server/graphql/resolvers/activities.py b/ayon_server/graphql/resolvers/activities.py index ef814474..5da34fbe 100644 --- a/ayon_server/graphql/resolvers/activities.py +++ b/ayon_server/graphql/resolvers/activities.py @@ -1,3 +1,5 @@ +from datetime import datetime + from ayon_server.graphql.connections import ActivitiesConnection from ayon_server.graphql.edges import ActivityEdge from ayon_server.graphql.nodes.activity import ActivityNode @@ -28,6 +30,8 @@ async def get_activities( activity_types: list[str] | None = None, reference_types: list[str] | None = None, activity_ids: list[str] | None = None, + changed_before: str | None = None, + changed_after: str | None = None, ) -> ActivitiesConnection: project_name = root.project_name @@ -60,6 +64,16 @@ async def get_activities( if activity_ids is not None: sql_conditions.append(f"activity_id IN {SQLTool.id_array(activity_ids)}") + if changed_before: + # ensure the date is a valid ISO 8601 datetime + changed_before_dt = datetime.fromisoformat(changed_before) + sql_conditions.append(f"updated_at < '{changed_before_dt.isoformat()}'") + + if changed_after: + # ensure the date is a valid ISO 8601 datetime + changed_after_dt = datetime.fromisoformat(changed_after) + sql_conditions.append(f"updated_at > '{changed_after_dt.isoformat()}'") + if activity_types is not None: validate_name_list(activity_types)