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

SG-37544 Include the "in" and "not_in" operators for payload optimization #362

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

carlos-villavicencio-adsk
Copy link
Contributor

@carlos-villavicencio-adsk carlos-villavicencio-adsk commented Dec 19, 2024

Summary

This is a follow up work from #360 in this case including support for in and not_in operators for lists of entities.

Affected methods

  • find
  • summarize
  • text_search (API query_display_name_cache)

Detailed Description

The change should transform calls like:

sg.find("Asset",
        [[
            "project", "in",
            [
                {
                    "created_at": datetime.datetime(2015, 12, 16, 11, 2, 10, tzinfo),
                    "id": 72,
                    "name": "Demo: Game",
                    "type": "Project",
                    # ...
                },
                {
                    "created_at": datetime.datetime(2015, 12, 16, 11, 2, 10, tzinfo),
                    "id": 73,
                    "name": "Demo: Game 2",
                    "type": "Project",
                    # ...
                }
            ]
        ]]
)

as if the following had been called:

sg.find('Asset', [['project', 'in', [{'id': 72, 'type': 'Project'}, {'id': 73, 'type': 'Project'}]]]) 

@carlos-villavicencio-adsk carlos-villavicencio-adsk requested a review from a team December 19, 2024 13:55
@carlos-villavicencio-adsk carlos-villavicencio-adsk changed the title SG-37544 Include the "in" and "not_in" for payload optimization SG-37544 Include the "in" and "not_in" operators for payload optimization Dec 19, 2024
}
],
}
os.environ["SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION"] = "1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this kind of test, in order to leave in the same state, I prefer to use a context:

from unittest import mock
with mock.patch.dict("os.environ", {
  "SHOTGUN_API_ENABLE_ENTITY_OPTIMIZATION": "1",
}):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found a way using a decorator for the test case.

Copy link
Contributor

@julien-lang julien-lang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Successfully merging this pull request may close these issues.

3 participants