diff --git a/app/apps/main/services/scales_control/redis_repository.py b/app/apps/main/services/scales_control/redis_repository.py index f0f7ce0..69020c6 100644 --- a/app/apps/main/services/scales_control/redis_repository.py +++ b/app/apps/main/services/scales_control/redis_repository.py @@ -12,10 +12,10 @@ from repcofkk.settings import REDIS_HOST, REDIS_PORT class RedisRepository(DashboardBaseService): def __init__( - self, - control_conveyor_month: str, - fabric_goal: str, - service: RedisService = RedisService(host=REDIS_HOST, port=REDIS_PORT, db=1), + self, + control_conveyor_month: str, + fabric_goal: str, + service: RedisService = RedisService(host=REDIS_HOST, port=REDIS_PORT, db=1), ): self.fabric_goal = fabric_goal self.control_conveyor_month = control_conveyor_month @@ -39,10 +39,14 @@ class RedisRepository(DashboardBaseService): f"{position.tag}.{interval}", "Date" ) if position_date_str is not None: - position_date = datetime.strptime( - position_date_str, "%Y-%m-%d %H:%M:%S.%f" - ) - + try: + position_date = datetime.strptime( + position_date_str, "%Y-%m-%d %H:%M:%S.%f" + ) + except Exception: + position_date = datetime.strptime( + position_date_str, "%Y-%m-%d %H:%M:%S" + ) scales[position.title] = ( int(float(position_value)) if int(float(position_value)) >= 0 else 0 ) @@ -78,9 +82,14 @@ class RedisRepository(DashboardBaseService): float(redis_service.hget_value(previous_shift_tag, "Value")) ) previous_date_str = redis_service.hget_value(previous_shift_tag, "Date") - previous_date = datetime.strptime( - previous_date_str, "%Y-%m-%d %H:%M:%S.%f" - ) + try: + previous_date = datetime.strptime( + previous_date_str, "%Y-%m-%d %H:%M:%S.%f" + ) + except Exception: + previous_date = datetime.strptime( + previous_date_str, "%Y-%m-%d %H:%M:%S" + ) previous_work_shift[position.title] = previous_value if latest_previous_shift_date: @@ -96,9 +105,14 @@ class RedisRepository(DashboardBaseService): float(redis_service.hget_value(current_shift_tag, "Value")) ) current_date_str = redis_service.hget_value(current_shift_tag, "Date") - current_date = datetime.strptime( - current_date_str, "%Y-%m-%d %H:%M:%S.%f" - ) + try: + current_date = datetime.strptime( + current_date_str, "%Y-%m-%d %H:%M:%S.%f" + ) + except Exception: + current_date = datetime.strptime( + current_date_str, "%Y-%m-%d %H:%M:%S" + ) current_work_shift[position.title] = current_value if latest_current_shift_date: