Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL: Add changedBefore and changedAfter args for activities resolver #438

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ayon_server/graphql/resolvers/activities.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down