Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
36ccddd1
Commit
36ccddd1
authored
6 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
OSB-28
: speed up latest observation controller and removed unuseful filtering of the data
parent
514acf7a
No related branches found
No related tags found
2 merge requests
!89
Monitoring maintenance Epic branch merge
,
!1
Resolve OSB-13 "Monitoringmaintenance "
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LCU/Maintenance/DBInterface/monitoringdb/views/controllers.py
+6
-12
6 additions, 12 deletions
...Maintenance/DBInterface/monitoringdb/views/controllers.py
with
6 additions
and
12 deletions
LCU/Maintenance/DBInterface/monitoringdb/views/controllers.py
+
6
−
12
View file @
36ccddd1
...
...
@@ -331,7 +331,7 @@ class ControllerLatestObservations(APIView):
return
Response
(
status
=
status
.
HTTP_406_NOT_ACCEPTABLE
,
data
=
'
Please specify both the start and the end date: %s
'
%
(
e
,))
rtsm_observation_entities
=
RTSMObservation
.
objects
.
order_by
(
'
-start_datetime
'
).
filter
(
rtsm_observation_entities
=
RTSMObservation
.
objects
.
filter
(
start_datetime__gte
=
self
.
from_date
)
for
group
in
self
.
station_group
:
if
group
is
not
'
A
'
:
...
...
@@ -342,7 +342,7 @@ class ControllerLatestObservations(APIView):
for
rtsm_observation_entity
in
rtsm_observation_entities
.
values
(
'
observation_id
'
,
'
start_datetime
'
,
'
end_datetime
'
).
\
distinct
():
distinct
()
.
order_by
(
'
-observation_id
'
)
:
observation_payload
=
OrderedDict
()
observation_payload
[
'
observation_id
'
]
=
rtsm_observation_entity
[
'
observation_id
'
]
...
...
@@ -351,18 +351,16 @@ class ControllerLatestObservations(APIView):
rtsm_list
=
RTSMObservation
.
objects
.
filter
(
start_datetime__gte
=
self
.
from_date
,
observation_id
=
rtsm_observation_entity
[
'
observation_id
'
]).
\
order_by
(
'
-start_datetime
'
)
observation_id
=
rtsm_observation_entity
[
'
observation_id
'
])
unique_modes
=
[
item
[
'
errors__mode
'
]
for
item
in
rtsm_list
.
values
(
'
errors__mode
'
).
distinct
()]
observation_payload
[
'
mode
'
]
=
unique_modes
observation_payload
[
'
total_component_errors
'
]
=
0
station_list
=
rtsm_list
.
values
(
'
station
'
).
distinct
()
station_involved_list
=
list
()
for
station
in
station_list
:
rtsm_entry_per_station
=
rtsm_list
.
filter
(
station__pk
=
station
[
'
station
'
]).
first
()
for
rtsm_entry_per_station
in
rtsm_list
.
order_by
(
'
station__name
'
):
station_summary
=
OrderedDict
()
station_summary
[
'
station_name
'
]
=
rtsm_entry_per_station
.
station
.
name
...
...
@@ -376,9 +374,6 @@ class ControllerLatestObservations(APIView):
observation_payload
[
'
total_component_errors
'
]
+=
station_summary
[
'
n_errors
'
]
station_involved_list
=
sorted
(
station_involved_list
,
key
=
lambda
rtsm_per_station
:
rtsm_per_station
[
'
n_errors
'
],
reverse
=
True
)
observation_payload
[
'
station_involved
'
]
=
station_involved_list
response_payload
.
append
(
observation_payload
)
...
...
@@ -388,8 +383,7 @@ class ControllerLatestObservations(APIView):
lambda
station_entry
:
len
(
station_entry
[
'
total_component_errors
'
])
>
0
,
response_payload
)
response_payload
=
sorted
(
response_payload
,
key
=
lambda
item
:
item
[
'
total_component_errors
'
],
reverse
=
True
)
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
response_payload
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment