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

Commit

Permalink
Merge pull request #3345 from pypeclub/bugfix/fix_last_vesrsion_query
Browse files Browse the repository at this point in the history
General: Fix last version function
  • Loading branch information
iLLiCiTiT authored Jun 15, 2022
2 parents 2242fa5 + 6753213 commit 817fbef
Showing 1 changed file with 7 additions and 4 deletions.
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

0 comments on commit 817fbef

Please sign in to comment.