def _get_data(self): today = timezone.now().date() cases = [] total_num = 0 fail_num = 0 for probe in ServiceHistory.objects.filter( Q(id=self.probe_id) | Q(main_probe=self.probe_id), created__year=today.year, created__month=today.month, created__day=today.day, ): try: agent = Agent.objects.get(id=probe.agent_id).name except Agent.DoesNotExist: continue param = '' if probe.request_params_id: try: param = AdditionalRequestParam.objects.get( id=probe.request_params_id, ).name except AdditionalRequestParam.DoesNotExist: continue cases.append({ 'agent_name': agent, 'request_params_name': param, 'state': ResponseStateChoices.raw_from_id(probe.response_state, ), }) if probe.response_state != ResponseStateChoices.ok: fail_num += 1 total_num += 1 return cases, fail_num, total_num
def _get_data(self): today = timezone.now().date() cases = [] total_num = 0 fail_num = 0 for probe in ServiceHistory.objects.filter( Q(id=self.probe_id) | Q(main_probe=self.probe_id), created__year=today.year, created__month=today.month, created__day=today.day, ): try: agent = Agent.objects.get(id=probe.agent_id).name except Agent.DoesNotExist: continue param = '' if probe.request_params_id: try: param = AdditionalRequestParam.objects.get( id=probe.request_params_id, ).name except AdditionalRequestParam.DoesNotExist: continue cases.append({ 'agent_name': agent, 'request_params_name': param, 'state': ResponseStateChoices.raw_from_id( probe.response_state, ), }) if probe.response_state != ResponseStateChoices.ok: fail_num += 1 total_num += 1 return cases, fail_num, total_num