Skip to content

Commit

Permalink
Merge pull request #2466 from AdrianGaudebert/1093195-date-report-list
Browse files Browse the repository at this point in the history
Fixes bug 1093195 - Correctly format date for report/list/ in Super Search.
  • Loading branch information
Peter Bengtsson committed Nov 6, 2014
2 parents 304ed3b + 0fac966 commit 4257be2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions webapp-django/crashstats/supersearch/tests/test_views.py
Expand Up @@ -5,7 +5,6 @@
from nose.tools import eq_, ok_

from django.core.urlresolvers import reverse
from django.utils.timezone import utc

from waffle import Switch

Expand Down Expand Up @@ -784,15 +783,18 @@ def test_get_report_list_parameters(self):
'date': ['<2013-01-01T10:00:00+00:00']
}
res = get_report_list_parameters(source)
eq_(res['date'], datetime.datetime(2013, 1, 1, 10).replace(tzinfo=utc))
eq_(res['date'], '2013-01-01 10:00:00')
ok_('range_value' not in res)
ok_('range_unit' not in res)

source = {
'date': ['>=2013-01-01T10:00:00+00:00']
}
res = get_report_list_parameters(source)
eq_(res['date'].date(), datetime.datetime.utcnow().date())
eq_(
res['date'].split(' ')[0],
datetime.datetime.utcnow().date().isoformat()
)
ok_('range_value' in res)
eq_(res['range_unit'], 'hours')

Expand All @@ -807,7 +809,7 @@ def test_get_report_list_parameters(self):
'build_id': ['12345', '~67890'],
}
res = get_report_list_parameters(source)
eq_(res['date'].date(), datetime.date(2013, 2, 1))
eq_(res['date'], '2013-02-01 10:00:00')
ok_('range_value' in res)
ok_(res['range_unit'], 'hours')

Expand Down
2 changes: 2 additions & 0 deletions webapp-django/crashstats/supersearch/views.py
Expand Up @@ -299,6 +299,8 @@ def to_hours(delta):
params['range_value'] = to_hours(upper - lower)
params['range_unit'] = 'hours'

params['date'] = params['date'].strftime('%Y-%m-%d %H:%M:%S')

return params


Expand Down

0 comments on commit 4257be2

Please sign in to comment.