Skip to content

Commit ee955b5

Browse files
committed
issue#1 time column causing assertion errors
bug fix for #issue1. time column used for paging has to match time_type ('local' or 'utc') otherwise you get an assertion error.
1 parent 140894c commit ee955b5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

dendra_api_client.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,12 @@ def get_datapoints(datastream_id,begins_at,ends_before=time_format(),time_type='
326326
'$sort[time]': "1",
327327
'$limit': "2016"
328328
}
329-
if(time_type != 'utc'):
329+
if(time_type == 'utc'):
330+
time_col = 't'
331+
else:
330332
query.update({ 'time_local': "true" })
331-
333+
time_col = 'lt'
334+
332335
# Dendra requires paging of 2,000 records maximum at a time.
333336
# To get around this, we loop through multiple requests and append
334337
# the results into a single dataset.
@@ -341,7 +344,7 @@ def get_datapoints(datastream_id,begins_at,ends_before=time_format(),time_type='
341344
bigjson = rjson
342345
while(len(rjson['data']) > 0):
343346
df = pd.DataFrame.from_records(bigjson['data'])
344-
time_last = df['lt'].max()
347+
time_last = df[time_col].max() # issue#1 miguel
345348
query['time[$gt]'] = time_last
346349
r = requests.get(url + 'datapoints', headers=headers, params=query)
347350
assert r.status_code == 200

0 commit comments

Comments
 (0)