Skip to content
Snippets Groups Projects
Commit 65b9110b authored by Mattia Mancini's avatar Mattia Mancini
Browse files

OSB-32: finished implementation of the station based list of errors

parent 4313627b
No related branches found
No related tags found
2 merge requests!89Monitoring maintenance Epic branch merge,!1Resolve OSB-13 "Monitoringmaintenance "
......@@ -642,7 +642,7 @@ class ControllerStationComponentErrors(ValidableReadOnlyView):
end_datetime__lte=self.to_date)
failing_component_types = station_tests.distinct('component_errors__component__type').values_list('component_errors__component__type')
print(failing_component_types)
for failing_component_type in failing_component_types:
failing_component_type = failing_component_type[0]
component_type_errors_list = list()
......@@ -673,19 +673,25 @@ class ControllerStationComponentErrors(ValidableReadOnlyView):
def collect_rtsm_errors(self):
station_entry = Station.objects.filter(name=self.station_name).first()
response_payload = OrderedDict()
print(dir(station_entry))
rtsm_observations = station_entry.rtsmobservation_set \
.filter(start_datetime__gte=self.from_date,
end_datetime__lte=self.to_date)
print(rtsm_observations)
failing_component_modes = rtsm_observations.distinct(
failing_component_modes = rtsm_observations.exclude(errors_summary__isnull=True).distinct(
'errors_summary__mode').values_list('errors_summary__mode')
for observing_mode in failing_component_modes:
observing_mode = observing_mode[0]
rtsm_errors_per_component_type = list()
response_payload[MODE_TO_COMPONENT[observing_mode]] = rtsm_errors_per_component_type
for rtsm_observation in rtsm_observations.order_by('-start_datetime'):
rtsm_summary = OrderedDict()
rtsm_errors_per_component_type.append(rtsm_summary)
rtsm_summary['test_type'] = 'R'
rtsm_summary['start_date'] = rtsm_observation.start_datetime
rtsm_summary['end_date'] = rtsm_observation.end_datetime
......@@ -696,22 +702,37 @@ class ControllerStationComponentErrors(ValidableReadOnlyView):
.filter(mode=observing_mode)\
.values('error_type', 'start_frequency',
'stop_frequency', 'percentage',
'error_type', 'samples', 'count', 'rcu')
'error_type', 'count', 'rcu')
for component_error in component_errors:
component_id = component_error['rcu']
percentage = component_error['percentage']
start_frequency = component_error['start_frequency']
stop_frequency = component_error['stop_frequency']
details = dict(percentage = component_error['percentage'],
start_frequency = component_error['start_frequency'],
stop_frequency = component_error['stop_frequency'],
count = component_error['count'])
error_type = component_error['error_type']
#TODO I AM HERE
if component_id not in component_errors:
component_errors_dict[str(component_id)] = list()
component_errors_dict[str(component_id)] += [dict(error_type=error_type, details=details)]
return response_payload
print(dir(component_error))
def compute_response(self):
self.from_date = parse_date(self.from_date)
self.to_date = parse_date(self.to_date)
station_test_errors = {}
rtsm_errors = {}
if self.test_type in ['S', 'B']:
station_test_errors = self.collect_station_test_errors()
if self.test_type in ['R', 'B']:
rtsm_errors = self.collect_rtsm_errors()
payload = OrderedDict()
for component_type in set(rtsm_errors.keys() | station_test_errors.keys()):
station_test_errors_per_type = station_test_errors.get(component_type, [])
rtsm_errors_per_type = rtsm_errors.get(component_type, [])
station_test_errors = self.collect_station_test_errors()
rtsm_errors = self.collect_rtsm_errors()
payload[component_type] = sorted(station_test_errors_per_type + rtsm_errors_per_type, key=lambda item: item['start_date'])
return Response(status=status.HTTP_200_OK, data=station_test_errors)
\ No newline at end of file
return Response(status=status.HTTP_200_OK, data=payload)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment