Skip to content

Commit

Permalink
various improvements (#900)
Browse files Browse the repository at this point in the history
* [requirements] upgrade

* [qa][previews] refactoring for setting main entity preview
  • Loading branch information
EvanBldy authored Dec 17, 2024
1 parent f6f0f5f commit 62493d0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ install_requires =
flask-migrate==4.0.7
flask-socketio==5.4.1
flask==3.1.0
gazu==0.10.20
gazu==0.10.21
gevent-websocket==0.10.1
gevent==24.11.1
gunicorn==23.0.0
Expand Down
8 changes: 2 additions & 6 deletions zou/app/blueprints/previews/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from zou.app.mixin import ArgsMixin
from zou.app.stores import file_store
from zou.app.services import (
assets_service,
comments_service,
chats_service,
deletion_service,
Expand All @@ -21,7 +20,6 @@
persons_service,
projects_service,
preview_files_service,
shots_service,
tasks_service,
user_service,
)
Expand Down Expand Up @@ -1111,13 +1109,11 @@ def put(self, preview_file_id):
preview_files_service.replace_extracted_frame_for_preview_file(
preview_file, frame_number
)
asset = entities_service.update_entity_preview(
entity = entities_service.update_entity_preview(
task["entity_id"],
preview_file_id,
)
assets_service.clear_asset_cache(asset["id"])
shots_service.clear_shot_cache(asset["id"])
return asset
return entity


class UpdatePreviewPositionResource(Resource, ArgsMixin):
Expand Down
8 changes: 1 addition & 7 deletions zou/app/blueprints/tasks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,16 +1609,10 @@ def put(self, task_id):
preview_file = preview_files_service.get_last_preview_file_for_task(
task_id
)
entity = entities_service.get_entity(task["entity_id"])
if preview_file is not None:
entities_service.update_entity_preview(
entity = entities_service.update_entity_preview(
task["entity_id"], preview_file["id"]
)
assets_service.clear_asset_cache(entity["id"])
shots_service.clear_shot_cache(entity["id"])
edits_service.clear_edit_cache(entity["id"])
shots_service.clear_episode_cache(entity["id"])
shots_service.clear_sequence_cache(entity["id"])
return entity


Expand Down
13 changes: 11 additions & 2 deletions zou/app/services/entities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
base_service,
projects_service,
notifications_service,
assets_service,
shots_service,
edits_service,
)
from zou.app.utils import (
date_helpers,
Expand Down Expand Up @@ -108,12 +111,13 @@ def update_entity_preview(entity_id, preview_file_id):
if entity is None:
raise EntityNotFoundException

entity_id = str(entity.id)
preview_file = PreviewFile.get(preview_file_id)
if preview_file is None:
raise PreviewFileNotFoundException

entity.update({"preview_file_id": preview_file.id})
clear_entity_cache(str(entity.id))
clear_entity_cache(entity_id)
events.emit(
"preview-file:set-main",
{"entity_id": entity_id, "preview_file_id": preview_file_id},
Expand All @@ -125,9 +129,14 @@ def update_entity_preview(entity_id, preview_file_id):
entity_type_name = entity_type.name.lower()
events.emit(
"%s:update" % entity_type_name,
{"%s_id" % entity_type_name: str(entity.id)},
{"%s_id" % entity_type_name: entity_id},
project_id=str(entity.project_id),
)
assets_service.clear_asset_cache(entity_id)
edits_service.clear_edit_cache(entity_id)
shots_service.clear_shot_cache(entity_id)
shots_service.clear_episode_cache(entity_id)
shots_service.clear_sequence_cache(entity_id)
return entity.serialize()


Expand Down
8 changes: 1 addition & 7 deletions zou/app/services/tasks_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,16 +1646,10 @@ def update_preview_file_info(preview_file):
project = projects_service.get_project(task.project_id)

if project["is_set_preview_automated"]:
entity_id = str(task.entity_id)
entity = entities_service.update_entity_preview(
entity_id,
task.entity_id,
preview_file["id"],
)
assets_service.clear_asset_cache(entity_id)
edits_service.clear_edit_cache(entity_id)
shots_service.clear_shot_cache(entity_id)
shots_service.clear_episode_cache(entity_id)
shots_service.clear_sequence_cache(entity_id)
return entity


Expand Down

0 comments on commit 62493d0

Please sign in to comment.