Skip to content

Commit

Permalink
issue #73, remove groupby/having clauses for PG support (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 authored and tomkralidis committed Dec 19, 2016
1 parent 7370da0 commit 7d78bf0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions GeoHealthCheck/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ def all_response_times(self):

@property
def first_run(self):
return self.runs.having(func.min(Run.checked_datetime)).group_by(
Run.checked_datetime).order_by(
return self.runs.order_by(
Run.checked_datetime.asc()).first()

@property
def last_run(self):
return self.runs.having(func.max(Run.checked_datetime)).group_by(
Run.checked_datetime).order_by(
return self.runs.order_by(
Run.checked_datetime.desc()).first()

@property
Expand Down Expand Up @@ -144,15 +142,15 @@ def snippet(self):

def runs_to_json(self):
runs = []
for run in self.runs.group_by(Run.checked_datetime).all():
for run in self.runs.order_by(Run.checked_datetime).all():
runs.append({'datetime': run.checked_datetime.isoformat(),
'value': run.response_time,
'success': 1 if run.success else 0})
return runs

def success_to_colors(self):
colors = []
for run in self.runs.group_by(Run.checked_datetime).all():
for run in self.runs.order_by(Run.checked_datetime).all():
if run.success == 1:
colors.append('#5CB85C') # green
else:
Expand Down

0 comments on commit 7d78bf0

Please sign in to comment.