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

Unable to specify correct filter to query and return all Project, Episode, and Shot fields together #273

Open
omac777 opened this issue Dec 13, 2022 · 9 comments

Comments

@omac777
Copy link

omac777 commented Dec 13, 2022

Using the following variables:

project_name = 'SuperStickman'
episode_name = 'Stic-101'

I want to extract ALL the Project, Episode and Shot fields together.

I tried these two different ways, but they don't display Project, Episode and Shot fields.

sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name],['episode.Episode.name', 'is', episode_name]], ['code', 'sg_sequence.Sequence.sg_status_list'])
sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list'])

How do I return a query result that returns ALL the Project, Episode and Shot fields together?

Thank you in advance.

@monkeydev
Copy link

monkeydev commented Dec 13, 2022 via email

@omac777
Copy link
Author

omac777 commented Dec 13, 2022

I just tried that:

sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list',  'episode.Episode.name', 'project.Project.name' ])

No fields from Episode are returned. Only fields from Shot and only the Project name.

{'type': 'Shot', 'id': 8341, 'code': 'blahcode', 'sg_sequence.Sequence.sg_status_list': 'blahstatus', 'project.Project.name': 'SuperStickman'}

@omac777
Copy link
Author

omac777 commented Dec 13, 2022

I tried this as well:

sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name],['episode.Episode.name', 'is', episode_name]], ['code', 'sg_sequence.Sequence.sg_status_list',  'episode.Episode.name', 'project.Project.name' ] )

But it returns with an error:

shotgun_api3.shotgun.Fault: API read() Shot.episode.Episode.name doesn't exist:
{"path"=>"episode.Episode.name", "relation"=>"is", "values"=>["Stic-101"]}

@monkeydev
Copy link

monkeydev commented Dec 13, 2022 via email

@omac777
Copy link
Author

omac777 commented Dec 13, 2022

Much appreciated. Thanks you will try those.

The shot is not linked to an episode.

@omac777
Copy link
Author

omac777 commented Dec 13, 2022

BINGO:

sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list',  'sg_sequence.Sequence.episode', 'sg_sequence.Sequence.episode.Episode.code' ] )

Returns:

{'type': 'Shot', 'id': 8345, 'code': 'blahcodes1', 'sg_sequence.Sequence.sg_status_list': 'blahstatus2', 'sg_sequence.Sequence.episode': {'id': 400, 'name': 'Stic-101', 'type': 'Episode'}, 'sg_sequence.Sequence.episode.Episode.code': 'Stic-101'}

Thank you. We've got what we need with this. :)

You're a super-hero monkeydev.

@omac777
Copy link
Author

omac777 commented Dec 13, 2022

How do I fetch the task name within this query as well?

sg_shots = sg.find("Shot", [['project.Project.name', 'is', project_name]], ['code', 'sg_sequence.Sequence.sg_status_list',  'sg_sequence.Sequence.episode', 'sg_sequence.Sequence.episode.Episode.code', 'task.Task.name' ] )

I tried to fetch it but it's empty as well. Not linked as you mentioned?

@josh-mission
Copy link

This is interesting, is there a way to use this style of syntax to extract specific fields for list relationships too?
Say I want to query Assets and also pull out additional fields for their related shots, and sequences.

Say I make this query: sg.find_one('Asset', [['code', 'is', 'sample_asset']], ["id", "code", "sg_status_list", "tasks", "shots"])

{
    "type": "Asset",
    "id": 1445,
    "code": "sample_asset",
    "sg_status_list": "wtg",
    "tasks": [
        {"id": 5868, "name": "Concept", "type": "Task"},
        {"id": 5869, "name": "Model", "type": "Task"},
    ],
    "shots": [
        {"id": 1211, "name": "sample_shot_1", "type": "Shot"},
        {"id": 1207, "name": "sample_shot_2", "type": "Shot"},
    ]
}

But I'd like to include additional fields in the Task and Shot lists. Is there a way to do that without having to make additional API calls specifically for Task and Shot?

@blerrgh
Copy link

blerrgh commented Jun 11, 2023

@josh-mission I don't believe that is possible for multi-entity fields. see: https://community.shotgridsoftware.com/t/using-linked-fields-aka-bubbled-fields-in-api-requests/8697

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants