Better display of wait times when they are under an hour. Bug 632136
This commit is contained in:
Родитель
c51e03c593
Коммит
7783e2da12
|
@ -34,7 +34,7 @@ def editor_page_title(context, title=None, addon=None):
|
|||
class EditorQueueTable(SQLTable):
|
||||
addon_name = tables.Column(verbose_name=_(u'Addon'))
|
||||
addon_type_id = tables.Column(verbose_name=_(u'Type'))
|
||||
waiting_time_days = tables.Column(verbose_name=_(u'Waiting Time'))
|
||||
waiting_time_min = tables.Column(verbose_name=_(u'Waiting Time'))
|
||||
flags = tables.Column(verbose_name=_(u'Flags'), sortable=False)
|
||||
applications = tables.Column(verbose_name=_(u'Applications'),
|
||||
sortable=False)
|
||||
|
@ -77,17 +77,21 @@ class EditorQueueTable(SQLTable):
|
|||
return (u'<div class="app-icon ed-sprite-admin-review" title="%s">'
|
||||
u'</div>' % _('Admin Review'))
|
||||
|
||||
def render_waiting_time_days(self, row):
|
||||
if row.waiting_time_days == 0:
|
||||
def render_waiting_time_min(self, row):
|
||||
if row.waiting_time_min == 0:
|
||||
r = _('moments ago')
|
||||
elif row.waiting_time_hours == 0:
|
||||
# L10n: first argument is number of minutes
|
||||
r = ngettext(u'{0} minute', u'{0} minutes',
|
||||
row.waiting_time_min).format(row.waiting_time_min)
|
||||
elif row.waiting_time_days == 0:
|
||||
# L10n: first argument is number of hours
|
||||
r = ngettext(u'{0} hour', u'{0} hours',
|
||||
row.waiting_time_hours).format(
|
||||
row.waiting_time_hours)
|
||||
row.waiting_time_hours).format(row.waiting_time_hours)
|
||||
else:
|
||||
# L10n: first argument is number of days
|
||||
r = ngettext(u'{0} day', u'{0} days',
|
||||
row.waiting_time_days).format(
|
||||
row.waiting_time_days)
|
||||
row.waiting_time_days).format(row.waiting_time_days)
|
||||
return jinja2.escape(r)
|
||||
|
||||
def set_page(self, page):
|
||||
|
@ -95,7 +99,7 @@ class EditorQueueTable(SQLTable):
|
|||
|
||||
class Meta:
|
||||
sortable = True
|
||||
columns = ['addon_name', 'addon_type_id', 'waiting_time_days',
|
||||
columns = ['addon_name', 'addon_type_id', 'waiting_time_min',
|
||||
'flags', 'applications', 'additional_info']
|
||||
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ class ViewQueue(RawSQLModel):
|
|||
_application_ids = models.CharField(max_length=255)
|
||||
waiting_time_days = models.IntegerField()
|
||||
waiting_time_hours = models.IntegerField()
|
||||
waiting_time_min = models.IntegerField()
|
||||
is_version_specific = False
|
||||
|
||||
def base_query(self):
|
||||
|
@ -127,7 +128,9 @@ class ViewFullReviewQueue(ViewQueue):
|
|||
'waiting_time_days':
|
||||
'TIMESTAMPDIFF(DAY, addons.nominationdate, NOW())',
|
||||
'waiting_time_hours':
|
||||
'TIMESTAMPDIFF(HOUR, addons.nominationdate, NOW())'
|
||||
'TIMESTAMPDIFF(HOUR, addons.nominationdate, NOW())',
|
||||
'waiting_time_min':
|
||||
'TIMESTAMPDIFF(MINUTE, addons.nominationdate, NOW())'
|
||||
})
|
||||
q['where'].extend(['files.status <> %s' % amo.STATUS_BETA,
|
||||
'addons.status IN (%s, %s)' % (
|
||||
|
@ -145,7 +148,9 @@ class VersionSpecificQueue(ViewQueue):
|
|||
'waiting_time_days':
|
||||
'TIMESTAMPDIFF(DAY, MAX(versions.created), NOW())',
|
||||
'waiting_time_hours':
|
||||
'TIMESTAMPDIFF(HOUR, MAX(versions.created), NOW())'
|
||||
'TIMESTAMPDIFF(HOUR, MAX(versions.created), NOW())',
|
||||
'waiting_time_min':
|
||||
'TIMESTAMPDIFF(MINUTE, MAX(versions.created), NOW())'
|
||||
})
|
||||
return q
|
||||
|
||||
|
|
|
@ -92,19 +92,35 @@ class TestViewPendingQueueTable(test_utils.TestCase):
|
|||
row = Mock()
|
||||
row.waiting_time_days = 10
|
||||
row.waiting_time_hours = 10 * 24
|
||||
eq_(self.table.render_waiting_time_days(row), u'10 days')
|
||||
eq_(self.table.render_waiting_time_min(row), u'10 days')
|
||||
|
||||
def test_waiting_time_one_day(self):
|
||||
row = Mock()
|
||||
row.waiting_time_days = 1
|
||||
row.waiting_time_hours = 24
|
||||
eq_(self.table.render_waiting_time_days(row), u'1 day')
|
||||
row.waiting_time_min = 60 * 24
|
||||
eq_(self.table.render_waiting_time_min(row), u'1 day')
|
||||
|
||||
def test_waiting_time_in_hours(self):
|
||||
row = Mock()
|
||||
row.waiting_time_days = 0
|
||||
row.waiting_time_hours = 22
|
||||
eq_(self.table.render_waiting_time_days(row), u'22 hours')
|
||||
row.waiting_time_min = 60 * 22
|
||||
eq_(self.table.render_waiting_time_min(row), u'22 hours')
|
||||
|
||||
def test_waiting_time_in_min(self):
|
||||
row = Mock()
|
||||
row.waiting_time_days = 0
|
||||
row.waiting_time_hours = 0
|
||||
row.waiting_time_min = 11
|
||||
eq_(self.table.render_waiting_time_min(row), u'11 minutes')
|
||||
|
||||
def test_waiting_time_in_secs(self):
|
||||
row = Mock()
|
||||
row.waiting_time_days = 0
|
||||
row.waiting_time_hours = 0
|
||||
row.waiting_time_min = 0
|
||||
eq_(self.table.render_waiting_time_min(row), u'moments ago')
|
||||
|
||||
def test_flags_admin_review(self):
|
||||
row = Mock()
|
||||
|
|
|
@ -201,5 +201,6 @@ class TestPreliminaryQueue(TestQueue):
|
|||
Version.objects.update(created=datetime.utcnow())
|
||||
row = self.Queue.objects.all()[0]
|
||||
eq_(row.waiting_time_days, 0)
|
||||
# Time zone will be off, hard to test this.
|
||||
# Time zone might be off due to your MySQL install, hard to test this.
|
||||
assert row.waiting_time_min is not None
|
||||
assert row.waiting_time_hours is not None
|
||||
|
|
|
@ -126,7 +126,7 @@ def _queue(request, TableObj, tab):
|
|||
review_num))
|
||||
except IndexError:
|
||||
pass
|
||||
order_by = request.GET.get('sort', '-waiting_time_days')
|
||||
order_by = request.GET.get('sort', '-waiting_time_min')
|
||||
table = TableObj(qs, order_by=order_by)
|
||||
queue_counts = _queue_counts()
|
||||
page = paginate(request, table.rows, per_page=100,
|
||||
|
|
Загрузка…
Ссылка в новой задаче