order by created, not id (bug 641582)
This commit is contained in:
Родитель
f4a1758a80
Коммит
6c686e68c5
|
@ -50,7 +50,7 @@ def dedupe_approvals(items, **kw):
|
|||
for addon in Addon.objects.filter(pk__in=items):
|
||||
last = {}
|
||||
for activity in (ActivityLog.objects.for_addons(addon)
|
||||
.order_by('-id')
|
||||
.order_by('-created')
|
||||
.filter(action__in=LOG_STATUSES)):
|
||||
arguments = json.loads(activity._arguments)
|
||||
current = {
|
||||
|
@ -71,4 +71,5 @@ def dedupe_approvals(items, **kw):
|
|||
log.info('Deleting duplicate activity log %s '
|
||||
'from addon %s' % (activity.pk, addon.pk))
|
||||
activity.delete()
|
||||
last = current.copy()
|
||||
else:
|
||||
last = current.copy()
|
||||
|
|
|
@ -117,3 +117,14 @@ class TestDedupeApprovals(test_utils.TestCase):
|
|||
amo.log(amo.LOG.APPROVE_VERSION, self.addon, self.version)
|
||||
dedupe_approvals([self.addon.pk])
|
||||
eq_(ActivityLog.objects.for_addons(self.addon).count(), 2)
|
||||
|
||||
def test_dedupe_not_id(self):
|
||||
date_one = datetime.today()
|
||||
date_two = datetime.today() - timedelta(days=1)
|
||||
for x in range(0, 4):
|
||||
log = amo.log(amo.LOG.APPROVE_VERSION, self.addon, self.version)
|
||||
log.update(created=date_one)
|
||||
log = amo.log(amo.LOG.REJECT_VERSION, self.addon, self.version)
|
||||
log.update(created=date_two)
|
||||
dedupe_approvals([self.addon.pk])
|
||||
eq_(ActivityLog.objects.for_addons(self.addon).count(), 2)
|
||||
|
|
Загрузка…
Ссылка в новой задаче