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

Commit

Permalink
Fixup _has_start_at method
Browse files Browse the repository at this point in the history
Need to use .get() to access a thing that might not exist.

Also use _timestamp because I think it's more widely used.
  • Loading branch information
alexmuller committed Nov 13, 2014
1 parent e254ead commit 0ad16eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backdrop/core/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ def execute_query(self, query):
if shift != 0:
return self.execute_query(query.get_shifted_query(shift))

if not query.sort_by and _has_start_at(data):
return sorted(data.data(), key=lambda d: d['_start_at'])
if _has_timestamp(data) and (not query.sort_by):
return sorted(data.data(), key=lambda d: d['_timestamp'])

return data.data()


def _has_start_at(data):
return all([data_point['_start_at'] for data_point in data.data()])
def _has_timestamp(data):
return all([data_point.get('_timestamp') for data_point in data.data()])


def build_data(results, query):
Expand Down

0 comments on commit 0ad16eb

Please sign in to comment.