From 5bec195a5796bfd401b9d261833e734524116de7 Mon Sep 17 00:00:00 2001 From: zakhy Date: Sat, 3 Aug 2024 21:18:04 +0700 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81?= =?UTF-8?q?=D0=B0=20=D1=84=D0=B0=D0=B1=D1=80=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/apps/main/services/workstatus/service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/apps/main/services/workstatus/service.py b/app/apps/main/services/workstatus/service.py index 679b2a0..f25c011 100644 --- a/app/apps/main/services/workstatus/service.py +++ b/app/apps/main/services/workstatus/service.py @@ -14,13 +14,13 @@ class WorkStatusService(DashboardBaseService): status_list = list(self.get_qs_by_range(start_month, now_date)) if not status_list: return {'last_status': 'WO', 'worktime': timedelta(0)} - if len(status_list) < 2: - return {'last_status': status_list[0]['status'], 'worktime': timezone.now() - status_list[0]['time']} last_status = status_list[-1] - start_status = status_list[-2] if last_status['time'] < (timezone.now() - timedelta(minutes=5)): logging.message(f'Fabric Stopped {timezone.now()} ({timezone.now() - timedelta(minutes=5)})') return {'last_status': 'NW', 'worktime': timezone.now() - last_status['time']} + if len(status_list) < 2: + return {'last_status': status_list[0]['status'], 'worktime': timezone.now() - status_list[0]['time']} + start_status = status_list[-2] while start_status['status'] == last_status['status'] and len(status_list) >= 1: start_status = status_list.pop() now_date = timezone.now()