Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Berlimor committed Apr 4, 2024
1 parent 1b63b16 commit f9ae1c1
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/unit/UnitManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

class UnitManager:
"""UnitManager class manages unit instances in the database."""
collection = "unitData"
database = BaseMongoDbWrapper

def __init__(
self,
Expand All @@ -33,8 +35,6 @@ def __init__(
components_units: list[Unit] = None,
status: UnitStatus | str = UnitStatus.production,
) -> None:
self.collection = "unitData"
self.database = BaseMongoDbWrapper
if unit_id:
self.unit_id = unit_id
else:
Expand Down Expand Up @@ -62,6 +62,7 @@ def _set_components_units(self, component: Unit) -> None:
BaseUnitWrapper.unit_update_single_field(self.unit_id, "components_units", cur_components)

@lru_cache(maxsize=4)
@property
def _get_cur_unit(self) -> Unit:
if self.unit_id is None:
raise ValueError("Unit id not found.")
Expand Down Expand Up @@ -167,15 +168,7 @@ def assign_component(self, component: Unit) -> None:
self._set_components_units(component)
component.featured_in_int_id = self._get_cur_unit().internal_id
logger.info(f"Component {component.model_name} has been assigned to a composite Unit {self.model_name}")
messenger.success(
translation("Component")
+ " "
+ component.model_name
+ " "
+ translation("AssignedToUnit")
+ " "
+ self.model_name
)
messenger.success(f"{translation("Component")} {component.model_name} {translation("AssignedToUnit")} {self.model_name}")

def start_operation(self, employee: Employee, additional_info: AdditionalInfo | None = None) -> None:
"""begin the provided operation and save data about it"""
Expand Down Expand Up @@ -252,4 +245,7 @@ async def end_operation(
)
metrics.register_complete_unit(None, self)

self.employee = None
self.employee = None



0 comments on commit f9ae1c1

Please sign in to comment.