Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

General: Fix last version function #3345

Merged
merged 2 commits into from
Jun 15, 2022
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
11 changes: 7 additions & 4 deletions openpype/client/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _get_project_connection(project_name=None):
return mongodb


def _prepare_fields(fields):
def _prepare_fields(fields, required_fields=None):
if not fields:
return None

Expand All @@ -33,6 +33,10 @@ def _prepare_fields(fields):
}
if "_id" not in output:
output["_id"] = True

if required_fields:
for key in required_fields:
output[key] = True
return output


Expand Down Expand Up @@ -655,9 +659,8 @@ def get_last_versions(project_name, subset_ids, fields=None):
doc["_version_id"]
for doc in conn.aggregate(_pipeline)
]
fields = _prepare_fields(fields)
if fields and "parent" not in fields:
fields.append("parent")

fields = _prepare_fields(fields, ["parent"])

version_docs = get_versions(
project_name, version_ids=version_ids, fields=fields
Expand Down