Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Fix/disallow order bys #51

Merged
merged 5 commits into from Feb 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions measurements/api/measurements.py
Expand Up @@ -271,11 +271,14 @@ def list_measurements(

q = current_app.db_session.query(*cols)\
.join(Report, Report.report_no == Measurement.report_no)\
.outerjoin(Label, Label.msm_no == Measurement.msm_no)\
.outerjoin(Input, Measurement.input_no == Input.input_no)
.outerjoin(Label, Label.msm_no == Measurement.msm_no)

if input_:
q = q.filter(Input.input.like('%{}%'.format(input_)))
q = q.join(Input, Measurement.input_no == Input.input_no)\
.filter(Input.input.like('%{}%'.format(input_)))
else:
q = q.outerjoin(Input, Measurement.input_no == Input.input_no)

if report_id:
q = q.filter(Report.report_id == report_id)
if probe_cc:
Expand Down Expand Up @@ -306,7 +309,6 @@ def list_measurements(
c_failure == False
))


if order_by is not None:
q = q.order_by('{} {}'.format(order_by, order))

Expand Down
8 changes: 2 additions & 6 deletions measurements/openapi/measurements.yml
Expand Up @@ -24,6 +24,7 @@ paths:
- name: input
in: query
type: string
minLength: 3 # `input` is handled by pg_trgm
description: The input (for example a URL or IP address) to search measurements for
- name: probe_cc
in: query
Expand Down Expand Up @@ -87,16 +88,11 @@ paths:
type: string
description: 'By which key the results should be ordered by (default: `test_start_time`)'
enum:
- report_id
- input
- test_start_time
- input
- probe_cc
- probe_asn
- test_name
# These are all equivalent
- index
- idx
- report_no
- name: order
in: query
type: string
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -23,7 +23,7 @@
"gulp-sourcemaps": "^2.2.0",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.9",
"jquery": "^2.2.1",
"jquery": "^3.0.0",
"metrics-graphics": "2.10",
"moment": "^2.17.0",
"node-sass": "^4.5.3",
Expand Down