Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Fix query params and remove unused limiter
Browse files Browse the repository at this point in the history
Ensure that '_timestamp' is used to fetch
data and that it is sorted descending.
  • Loading branch information
mattrco committed Jan 23, 2015
1 parent 24cc694 commit 7b03da1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 0 additions & 2 deletions backdrop/read/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from flask import Flask, jsonify, request
from flask_featureflags import FeatureFlag
from flask_limiter import Limiter

from .query import parse_query_from_request
from .validation import validate_request_args
Expand All @@ -27,7 +26,6 @@

app = Flask("backdrop.read.api")

limiter = Limiter(app)
feature_flags = FeatureFlag(app)

# Configuration
Expand Down
13 changes: 4 additions & 9 deletions backdrop/transformers/tasks/latest_dataset_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def get_read_params(transform_params, latest_timestamp):
read_params['duration'] = 1
read_params['period'] = transform_params['period']
else:
read_params['_start_at'] = latest_timestamp
read_params['start_at'] = latest_timestamp
read_params['sort_by'] = '_timestamp:descending'
return read_params


Expand All @@ -38,14 +39,8 @@ def is_latest_data(data_set_config, transform, latest_datum):
existing_data = data_set.get(query_parameters=read_params)

if existing_data['data']:
if 'period' in transform_params:
if existing_data['data'][0]['_start_at'] > latest_datum['_timestamp']:
return False
else:
# If we got more than one data point back, assume latest_data
# isn't the newest in the dataset.
if len(existing_data['data']) > 1:
return False
if existing_data['data'][0]['_timestamp'] > latest_datum['_timestamp']:
return False

return True

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ argh==0.25
Celery==3.1.17
Flask==0.10.1
Flask-FeatureFlags==0.4
Flask-Limiter==0.6.4
gunicorn==19.1.1
invoke
isodate==0.5.0
Expand Down
10 changes: 5 additions & 5 deletions tests/transformers/tasks/test_latest_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def test_compute(self, mock_dashboard, mock_dataset):
'data': [
{
'_count': 1.0,
'_end_at': '2015-01-19T00:00:00+00:00',
'_start_at': '2015-01-12T00:00:00+00:00'
'_end_at': '2012-01-19T00:00:00+00:00',
'_timestamp': '2012`-01-12T00:00:00+00:00'
}
]
}
Expand Down Expand Up @@ -102,12 +102,12 @@ def test_compute_old_date_range(self, mock_dashboard, mock_dataset):
{
'_count': 1.0,
'_end_at': '2015-01-19T00:00:00+00:00',
'_start_at': '2015-01-12T00:00:00+00:00'
'_timestamp': '2015-01-12T00:00:00+00:00'
},
{
'_count': 1.0,
'_end_at': '2015-01-19T00:00:00+00:00',
'_start_at': '2015-01-12T00:00:00+00:00'
'_timestamp': '2015-01-12T00:00:00+00:00'
}
]
}
Expand Down Expand Up @@ -137,7 +137,7 @@ def test_compute_old_date_period(self, mock_dashboard, mock_dataset):
'data': [
{
'_count': 1.0,
'_start_at': '2016-10-07T00:00:00+00:00'
'_timestamp': '2016-10-07T00:00:00+00:00'
}
]
}
Expand Down

0 comments on commit 7b03da1

Please sign in to comment.