Рефакторинг получения статуса фабрики
This commit is contained in:
parent
8a6aaf69d1
commit
6706bd0d69
@ -50,11 +50,10 @@ def factory_work_time(request):
|
||||
def get_current_status(request):
|
||||
now_date = timezone.now()
|
||||
start_month = now_date - relativedelta(hours=730)
|
||||
status_list = list(FabricWorkTime.objects.filter(time__range=(start_month, now_date)))
|
||||
status_list = get_qs_by_range(FabricWorkTime, start_month, now_date)
|
||||
last_status = status_list[-1]
|
||||
start_status = status_list[-2]
|
||||
while start_status.status == last_status.status:
|
||||
while start_status['status'] == last_status['status']:
|
||||
start_status = status_list.pop()
|
||||
|
||||
status_worktime = last_status.time - start_status.time
|
||||
return JsonResponse({'last_status': last_status.status, 'worktime': status_worktime})
|
||||
status_worktime = last_status['time'] - start_status['time']
|
||||
return JsonResponse({'last_status': last_status['status'], 'worktime': status_worktime})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user