From 730be772a41538afce4f8e1a567ccb1c79efb5f2 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 15 Oct 2020 18:18:17 +0200 Subject: [PATCH] implemented finding of latest version --- pype/lib.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pype/lib.py b/pype/lib.py index 8f5c4527a0..527db4a38a 100644 --- a/pype/lib.py +++ b/pype/lib.py @@ -1429,9 +1429,28 @@ def get_latest_version(asset_name, subset_name, dbcon=None, project_name=None): project_name = dbcon.Session.get("AVALON_PROJECT") collection = dbcon + # Query asset document id by asset name + asset_doc = collection.find_one( + {"type": "asset", "name": asset_name}, + {"_id": True} ) + if not asset_doc: + return None + subset_doc = collection.find_one( + {"type": "subset", "name": subset_name, "parent": asset_doc["_id"]}, + {"_id": True} + ) + if not subset_doc: + return None + version_doc = collection.find_one( + {"type": "version", "parent": subset_doc["_id"]}, + sort=[("name", -1)], + ) + if not version_doc: + return None + return version_doc class ApplicationLaunchFailed(Exception):