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()