aboutsummaryrefslogtreecommitdiff
path: root/app/handlers/base.py
diff options
context:
space:
mode:
authorMilo Casagrande <milo.casagrande@linaro.org>2014-05-15 16:54:39 +0200
committerMilo Casagrande <milo.casagrande@linaro.org>2014-05-15 16:54:39 +0200
commitdba97b877c765025d9baf86fa425c7934a959e38 (patch)
treeaa49e9b5c9b5e4358763a401940d4bd44c578b5e /app/handlers/base.py
parentf455dff7411d888c9085e90a1488466d523accfb (diff)
Fix created attribute.
* Apparently, mongodb internally has a field called 'created', that collides with the 'created' attribute we have in the models. Sort operations on that field returned weird results when you drop the DB and re-import everything and are expecting to see the real documents date. * Rename created models attribute into created_on, and move it into the base model. * Fix tests.
Diffstat (limited to 'app/handlers/base.py')
-rw-r--r--app/handlers/base.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/handlers/base.py b/app/handlers/base.py
index 01326b7..89990af 100644
--- a/app/handlers/base.py
+++ b/app/handlers/base.py
@@ -369,7 +369,10 @@ class BaseHandler(RequestHandler):
date_range = self.get_query_argument('date_range', default=None)
if date_range:
- today = datetime.combine(date.today(), time(tzinfo=tz_util.utc))
+ # Today needs to be set at the end of the day!
+ today = datetime.combine(
+ date.today(), time(23, 59, 59, tzinfo=tz_util.utc)
+ )
previous = self._calculate_date_range(date_range)
spec['created'] = {'$gte': previous, '$lt': today}
@@ -456,6 +459,8 @@ class BaseHandler(RequestHandler):
if date_range > timedelta.max.days:
date_range = DEFAULT_DATE_RANGE
+ # Calcuate with midnight in mind though, so we get the starting of
+ # the day for the previous date.
today = datetime.combine(
date.today(), time(tzinfo=tz_util.utc)
)