Skip to content

Commit

Permalink
Merge pull request #733 from EvanBldy/master
Browse files Browse the repository at this point in the history
various improvements
  • Loading branch information
EvanBldy authored Nov 2, 2023
2 parents db8ae2d + 4308a88 commit 7c9cddd
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
16 changes: 8 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ classifiers =
zip_safe = False
packages = find:
install_requires =
babel==2.13.0
babel==2.13.1
click==8.1.7
discord.py==2.3.2
email-validator==2.1.0.post1
Expand Down Expand Up @@ -54,9 +54,9 @@ install_requires =
Jinja2==3.1.2
ldap3==2.9.1
matterhook==0.2
meilisearch==0.28.3
meilisearch==0.28.4
OpenTimelineIO==0.15.0
orjson==3.9.9
orjson==3.9.10
pillow==10.1.0
psutil==5.9.6
psycopg[binary]==3.1.12
Expand All @@ -72,7 +72,7 @@ install_requires =
sqlalchemy_utils==0.41.1
sqlalchemy==2.0.22
ua-parser==0.18.0
werkzeug==3.0.0
werkzeug==3.0.1

[options.package_data]
* = app/file_trees/*.json,migrations/*,migrations/versions/*.py
Expand All @@ -93,15 +93,15 @@ test =
fakeredis==2.20.0
mixer==7.2.2
pytest-cov==4.1.0
pytest==7.4.2
pytest==7.4.3

monitoring =
prometheus-flask-exporter==0.22.4
prometheus-flask-exporter==0.23.0
pygelf==0.4.2
sentry-sdk==1.32.0
sentry-sdk==1.33.1

lint =
black==23.10.0
black==23.10.1
pre-commit==3.5.0

[options.entry_points]
Expand Down
1 change: 1 addition & 0 deletions zou/app/blueprints/auth/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def is_from_browser(user_agent):
"Chrome",
"Edge",
"Firefox",
"Mobile Safari",
"Opera",
"Safari",
"Vivaldi",
Expand Down
34 changes: 25 additions & 9 deletions zou/app/blueprints/source/csv/casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def prepare_import(self, project_id):
self.asset_type_map = {}
self.asset_map = {}
self.episode_map = {}
self.episode_name_map = {}
self.sequence_map = {}
self.shot_map = {}

Expand All @@ -62,6 +63,8 @@ def prepare_import(self, project_id):
episodes = shots_service.get_episodes({"project_id": project_id})
for episode in episodes:
self.episode_map[episode["id"]] = slugify(episode["name"])
key = self.get_episode_key(episode)
self.episode_name_map[key] = episode["id"]

sequences = shots_service.get_sequences({"project_id": project_id})
for sequence in sequences:
Expand All @@ -75,34 +78,38 @@ def prepare_import(self, project_id):

def get_asset_key(self, asset):
asset_type_name = self.asset_type_map[asset["entity_type_id"]]
return "%s%s" % (asset_type_name, slugify(asset["name"]))
return f"{asset_type_name}{slugify(asset['name'])}"

def get_sequence_key(self, sequence):
episode_name = ""
if sequence["parent_id"] in self.episode_map:
episode_name = self.episode_map[sequence["parent_id"]]
return "%s%s" % (episode_name, slugify(sequence["name"]))
return f"{episode_name}{slugify(sequence['name'])}"

def get_shot_key(self, shot):
sequence_key = self.sequence_map[shot["parent_id"]]
return "%s%s" % (sequence_key, slugify(shot["name"]))
return f"{sequence_key}{slugify(shot['name'])}"

def get_episode_key(self, episode):
return f"episode{slugify(episode['name'])}"

def import_row(self, row, project_id):
asset_key = slugify("%s%s" % (row["Asset Type"], row["Asset"]))
if row.get("Episode") == "MP":
asset_key = slugify(f"{row['Asset Type']}{row['Asset']}")
if row.get("Episode") in ["MP", None]:
row["Episode"] = ""
target_key = slugify(
"%s%s%s" % (row.get("Episode", ""), row["Parent"], row["Name"])
)
target_key = slugify(f"{row['Episode']}{row['Parent']}{row['Name']}")
occurences = 1
if len(row["Occurences"]) > 0:
occurences = int(row["Occurences"])

asset_id = self.asset_map.get(asset_key, None)
target_id = self.shot_map.get(target_key, None)
label = slugify(row.get("Label", "fixed"))
if target_id is None:
target_id = self.asset_map.get(target_key, None)
if target_id is None:
target_id = self.episode_name_map.get(target_key, None)

label = slugify(row.get("Label", "fixed"))

if asset_id is not None and target_id is not None:
entity = entities_service.get_entity_raw(target_id)
Expand All @@ -127,6 +134,15 @@ def import_row(self, row, project_id):
},
project_id=str(entity.project_id),
)
elif shots_service.is_episode(entity.serialize()):
events.emit(
"episode:casting-update",
{
"episode_id": entity_id,
"nb_entities_out": entity.nb_entities_out,
},
project_id=str(entity.project_id),
)
else:
events.emit(
"asset:casting-update",
Expand Down
2 changes: 1 addition & 1 deletion zou/app/services/breakdown_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def update_casting(entity_id, casting):
events.emit(
"asset:update",
{"asset_id": cast["asset_id"]},
project_id=entity.project_id,
project_id=str(entity.project_id),
)

entity_id = str(entity.id)
Expand Down

0 comments on commit 7c9cddd

Please sign in to comment.