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
1271e4a3
Commit
1271e4a3
authored
6 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
OSB-28
: slight change in the query syntax and shape of the output
parent
0b479eaa
No related branches found
No related tags found
2 merge requests
!89
Monitoring maintenance Epic branch merge
,
!1
Resolve OSB-13 "Monitoringmaintenance "
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
LCU/Maintenance/DBInterface/monitoringdb/urls.py
+1
-0
1 addition, 0 deletions
LCU/Maintenance/DBInterface/monitoringdb/urls.py
LCU/Maintenance/DBInterface/monitoringdb/views/controllers.py
+32
-32
32 additions, 32 deletions
...Maintenance/DBInterface/monitoringdb/views/controllers.py
with
33 additions
and
32 deletions
LCU/Maintenance/DBInterface/monitoringdb/urls.py
+
1
−
0
View file @
1271e4a3
...
@@ -41,6 +41,7 @@ urlpatterns = [
...
@@ -41,6 +41,7 @@ urlpatterns = [
url
(
r
'
^api/view/ctrl_stationtestsummary
'
,
ControllerStationTestsSummary
.
as_view
()),
url
(
r
'
^api/view/ctrl_stationtestsummary
'
,
ControllerStationTestsSummary
.
as_view
()),
url
(
r
'
^api/view/ctrl_latest_observation
'
,
ControllerLatestObservations
.
as_view
()),
url
(
r
'
^api/view/ctrl_latest_observation
'
,
ControllerLatestObservations
.
as_view
()),
url
(
r
'
^api/view/ctrl_stationtest_statistics
'
,
ControllerStationTestStatistics
.
as_view
()),
url
(
r
'
^api/view/ctrl_stationtest_statistics
'
,
ControllerStationTestStatistics
.
as_view
()),
url
(
r
'
^api/view/ctrl_list_component_error_types
'
,
ControllerAllComponentErrorTypes
.
as_view
()),
url
(
r
'
^api/docs
'
,
include_docs_urls
(
title
=
'
Monitoring DB API
'
))
url
(
r
'
^api/docs
'
,
include_docs_urls
(
title
=
'
Monitoring DB API
'
))
]
]
This diff is collapsed.
Click to expand it.
LCU/Maintenance/DBInterface/monitoringdb/views/controllers.py
+
32
−
32
View file @
1271e4a3
...
@@ -84,9 +84,9 @@ class ControllerStationOverview(APIView):
...
@@ -84,9 +84,9 @@ class ControllerStationOverview(APIView):
station_payload
[
'
station_name
'
]
=
station_entity
.
name
station_payload
[
'
station_name
'
]
=
station_entity
.
name
station_test_list
=
StationTest
.
objects
.
filter
(
station_test_list
=
StationTest
.
objects
.
filter
(
station__name
=
station_entity
.
name
).
order_by
(
'
-end_datetime
'
)[:
n_station_tests
-
1
]
station__name
=
station_entity
.
name
).
order_by
(
'
-end_datetime
'
)[:
n_station_tests
]
rtsm_list
=
RTSMObservation
.
objects
.
filter
(
rtsm_list
=
RTSMObservation
.
objects
.
filter
(
station__name
=
station_entity
.
name
).
order_by
(
'
-end_datetime
'
)[:
n_rtsm
-
1
]
station__name
=
station_entity
.
name
).
order_by
(
'
-end_datetime
'
)[:
n_rtsm
]
station_payload
[
'
station_tests
'
]
=
list
()
station_payload
[
'
station_tests
'
]
=
list
()
for
station_test
in
station_test_list
:
for
station_test
in
station_test_list
:
...
@@ -155,6 +155,7 @@ class ControllerStationTestsSummary(APIView):
...
@@ -155,6 +155,7 @@ class ControllerStationTestsSummary(APIView):
DEFAULT_STATION_GROUP
=
'
A
'
DEFAULT_STATION_GROUP
=
'
A
'
DEFAULT_ONLY_ERRORS
=
True
DEFAULT_ONLY_ERRORS
=
True
DEFAULT_N_STATION_TESTS
=
4
queryset
=
StationTest
.
objects
.
all
()
queryset
=
StationTest
.
objects
.
all
()
schema
=
ManualSchema
(
fields
=
[
schema
=
ManualSchema
(
fields
=
[
...
@@ -173,18 +174,11 @@ class ControllerStationTestsSummary(APIView):
...
@@ -173,18 +174,11 @@ class ControllerStationTestsSummary(APIView):
description
=
'
displays or not only the station with more than one error
'
)
description
=
'
displays or not only the station with more than one error
'
)
),
),
coreapi
.
Field
(
coreapi
.
Field
(
"
start_date
"
,
"
n_station_tests
"
,
required
=
True
,
required
=
False
,
location
=
'
query
'
,
schema
=
coreschema
.
String
(
description
=
'
select station tests from date (ex. YYYY-MM-DD)
'
)
),
coreapi
.
Field
(
"
end_date
"
,
required
=
True
,
location
=
'
query
'
,
location
=
'
query
'
,
schema
=
coreschema
.
String
(
schema
=
coreschema
.
Integer
(
description
=
'
number of station tests to select
'
,
description
=
'
select station tests to date (ex. YYYY-MM-DD)
'
)
minimum
=
1
)
)
)
]
]
)
)
...
@@ -202,21 +196,18 @@ class ControllerStationTestsSummary(APIView):
...
@@ -202,21 +196,18 @@ class ControllerStationTestsSummary(APIView):
self
.
errors_only
=
request
.
query_params
.
get
(
'
errors_only
'
,
self
.
DEFAULT_ONLY_ERRORS
)
self
.
errors_only
=
request
.
query_params
.
get
(
'
errors_only
'
,
self
.
DEFAULT_ONLY_ERRORS
)
self
.
station_group
=
request
.
query_params
.
get
(
'
station_group
'
,
self
.
DEFAULT_STATION_GROUP
)
self
.
station_group
=
request
.
query_params
.
get
(
'
station_group
'
,
self
.
DEFAULT_STATION_GROUP
)
start_date
=
request
.
query_params
.
get
(
'
start_date
'
)
self
.
n_station_tests
=
int
(
request
.
query_params
.
get
(
'
n_station_tests
'
,
self
.
start_date
=
ControllerStationTestsSummary
.
parse_date
(
start_date
)
self
.
DEFAULT_N_STATION_TESTS
))
end_date
=
request
.
query_params
.
get
(
'
end_date
'
)
self
.
end_date
=
ControllerStationTestsSummary
.
parse_date
(
end_date
)
def
get
(
self
,
request
,
format
=
None
):
def
get
(
self
,
request
,
format
=
None
):
try
:
try
:
self
.
validate_query_parameters
(
request
)
self
.
validate_query_parameters
(
request
)
except
ValueError
as
e
:
except
ValueError
as
e
:
return
Response
(
status
=
status
.
HTTP_406_NOT_ACCEPTABLE
,
return
Response
(
status
=
status
.
HTTP_406_NOT_ACCEPTABLE
,
data
=
'
Please specify the
date in the format YYYY-MM-DD
: %s
'
%
(
e
,))
data
=
'
Please specify the
correct parameters
: %s
'
%
(
e
,))
except
KeyError
as
e
:
except
KeyError
as
e
:
return
Response
(
status
=
status
.
HTTP_406_NOT_ACCEPTABLE
,
return
Response
(
status
=
status
.
HTTP_406_NOT_ACCEPTABLE
,
data
=
'
Please specify
both
the
start and the end date
: %s
'
%
(
e
,))
data
=
'
Please specify
all
the
required parameters
: %s
'
%
(
e
,))
station_entities
=
Station
.
objects
.
all
()
station_entities
=
Station
.
objects
.
all
()
for
group
in
self
.
station_group
:
for
group
in
self
.
station_group
:
...
@@ -226,22 +217,21 @@ class ControllerStationTestsSummary(APIView):
...
@@ -226,22 +217,21 @@ class ControllerStationTestsSummary(APIView):
# Since django preferes a ordered dict over a dict we make it happy... for now
# Since django preferes a ordered dict over a dict we make it happy... for now
response_payload
=
list
()
response_payload
=
list
()
for
station_entity
in
station_entities
:
for
station_entity
in
station_entities
:
station_payload
=
OrderedDict
()
station_payload
[
'
station_name
'
]
=
station_entity
.
name
station_test_list
=
StationTest
.
objects
.
filter
(
start_datetime__gte
=
self
.
start_date
,
station_test_list
=
StationTest
.
objects
.
\
end_datetime__lte
=
self
.
end_date
,
filter
(
station__name
=
station_entity
.
name
).
order_by
(
'
-end_datetime
'
)[:
self
.
n_station_tests
]
station__name
=
station_entity
.
name
).
order_by
(
'
-end_datetime
'
)
station_payload
[
'
station_tests
'
]
=
list
()
for
station_test
in
station_test_list
:
for
station_test
in
station_test_list
:
station_test_payload
=
OrderedDict
()
station_test_payload
=
OrderedDict
()
component_errors
=
station_test
.
component_errors
component_errors
=
station_test
.
component_errors
station_test_payload
[
'
station_name
'
]
=
station_entity
.
name
station_test_payload
[
station_test_payload
[
'
total_component_errors
'
]
=
station_test
.
component_errors
.
count
()
'
total_component_errors
'
]
=
station_test
.
component_errors
.
count
()
station_test_payload
[
'
date
'
]
=
station_test
.
start_datetime
.
strftime
(
'
%Y-%m-%d
'
)
station_test_payload
[
'
start_datetime
'
]
=
station_test
.
start_datetime
station_test_payload
[
'
start_datetime
'
]
=
station_test
.
start_datetime
station_test_payload
[
'
end_datetime
'
]
=
station_test
.
end_datetime
station_test_payload
[
'
end_datetime
'
]
=
station_test
.
end_datetime
station_test_payload
[
'
checks
'
]
=
station_test
.
checks
station_test_payload
[
'
checks
'
]
=
station_test
.
checks
...
@@ -261,15 +251,15 @@ class ControllerStationTestsSummary(APIView):
...
@@ -261,15 +251,15 @@ class ControllerStationTestsSummary(APIView):
item_error_total
item_error_total
station_test_payload
[
'
component_error_summary
'
]
=
component_errors_summary_dict
station_test_payload
[
'
component_error_summary
'
]
=
component_errors_summary_dict
station_payload
[
'
station_tests
'
].
append
(
station_test_payload
)
response_payload
.
append
(
station_test_payload
)
response_payload
.
append
(
station_payload
)
if
self
.
errors_only
and
self
.
errors_only
is
not
'
false
'
:
if
self
.
errors_only
and
self
.
errors_only
is
not
'
false
'
:
response_payload
=
filter
(
response_payload
=
filter
(
lambda
station_entry
:
lambda
station_
test_
entry
:
len
(
station_entry
[
'
station_test
s
'
]
)
>
0
,
station_
test_
entry
[
'
total_component_error
s
'
]
>
0
,
response_payload
)
response_payload
)
response_payload
=
sorted
(
response_payload
,
key
=
lambda
item
:
item
[
'
station_name
'
])
response_payload
=
sorted
(
response_payload
,
key
=
lambda
item
:
item
[
'
station_name
'
])
response_payload
=
sorted
(
response_payload
,
key
=
lambda
item
:
item
[
'
date
'
],
reverse
=
True
)
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
response_payload
)
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
response_payload
)
...
@@ -640,3 +630,13 @@ result:
...
@@ -640,3 +630,13 @@ result:
response_payload
[
'
errors_per_type
'
]
=
errors_per_type
response_payload
[
'
errors_per_type
'
]
=
errors_per_type
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
response_payload
)
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
response_payload
)
class
ControllerAllComponentErrorTypes
(
APIView
):
"""
Returns all distinct component errors
"""
def
get
(
self
,
request
,
format
=
None
):
data
=
[
item
[
'
type
'
]
for
item
in
ComponentError
.
objects
.
values
(
'
type
'
).
distinct
()]
return
Response
(
status
=
status
.
HTTP_200_OK
,
data
=
data
)
\ No newline at end of file
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