mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
use 'created_dt' of representation
This commit is contained in:
parent
e359fb3d84
commit
a76ad60351
2 changed files with 44 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ that has project name as a context (e.g. on 'ProjectEntity'?).
|
|||
+ We will need more specific functions doing wery specific queires really fast.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
import re
|
||||
import collections
|
||||
|
||||
|
|
@ -1367,6 +1368,33 @@ def get_representation_parents(project_name, representation):
|
|||
return parents_by_repre_id[repre_id]
|
||||
|
||||
|
||||
def get_representation_last_created_time_on_site(
|
||||
representation: dict, site_name: str
|
||||
) -> datetime:
|
||||
"""Get `created_dt` value for representation on site.
|
||||
|
||||
Args:
|
||||
representation (dict): Representation to get creation date of
|
||||
site_name (str): Site from which to get the creation date
|
||||
|
||||
Returns:
|
||||
datetime: Created time of representation on site
|
||||
"""
|
||||
created_time = next(
|
||||
(
|
||||
site.get("created_dt")
|
||||
for site in representation["files"][0].get("sites", [])
|
||||
if site["name"] == site_name
|
||||
),
|
||||
None,
|
||||
)
|
||||
if created_time:
|
||||
return created_time
|
||||
else:
|
||||
# Use epoch as 'zero' time
|
||||
return datetime.utcfromtimestamp(0)
|
||||
|
||||
|
||||
def get_thumbnail_id_from_source(project_name, src_type, src_id):
|
||||
"""Receive thumbnail id from source entity.
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import shutil
|
|||
from time import sleep
|
||||
from openpype.client.entities import (
|
||||
get_last_version_by_subset_id,
|
||||
get_representation_by_id,
|
||||
get_representation_last_created_time_on_site,
|
||||
get_representations,
|
||||
get_subsets,
|
||||
)
|
||||
|
|
@ -158,18 +160,29 @@ class CopyLastPublishedWorkfile(PreLaunchHook):
|
|||
)
|
||||
return
|
||||
|
||||
local_site_id = get_local_site_id()
|
||||
requests.post(
|
||||
rest_api_url,
|
||||
json={
|
||||
"project_name": project_name,
|
||||
"sites": [get_local_site_id()],
|
||||
"sites": [local_site_id],
|
||||
"representations": [str(workfile_representation["_id"])],
|
||||
},
|
||||
)
|
||||
|
||||
# Wait for the download loop to end
|
||||
rest_api_url = "{}/files_are_processed".format(entry_point_url)
|
||||
while requests.get(rest_api_url).content:
|
||||
last_created_time = get_representation_last_created_time_on_site(
|
||||
workfile_representation, local_site_id
|
||||
)
|
||||
while (
|
||||
last_created_time
|
||||
>= get_representation_last_created_time_on_site(
|
||||
get_representation_by_id(
|
||||
project_name, workfile_representation["_id"]
|
||||
),
|
||||
local_site_id,
|
||||
)
|
||||
):
|
||||
sleep(5)
|
||||
|
||||
# Get paths
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue