Skip to content

Filter syntax 'in_last', 'in_next' - add minute #385

@patrickwolf

Description

@patrickwolf

Currently we are limited by hour,day,week,month,year but often minute is very helpful to allow being more granular.
One use case is to query all events that were produced in the last 5 minutes

'in_last'                   [[int], 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR']
                                   # note that brackets are not literal (eg. ['start_date', 'in_last', 1, 'DAY'])
'in_next'                   [[int], 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR']
                                   # note that brackets are not literal (eg. ['start_date', 'in_next', 1, 'DAY'])

link to docs

for those that need minutes until the api supports it

import datetime
from datetime import timezone

# Get current time in UTC (which Shotgrid API uses)
now = datetime.datetime.now(timezone.utc)

# Calculate timestamp for minutes ago
minutes_ago = now - datetime.timedelta(minutes=minutes)

filters = [
    ['created_at', 'greater_than', minutes_ago],  # Use timestamp directly
]

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions