def test_dedupe_date(self): # Test that a log spanning old = amo.log(amo.LOG.APPROVE_VERSION, self.addon, self.version) old.update(created=datetime.today() - timedelta(days=1)) 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_mix(self): for x in range(0, 4): amo.log(amo.LOG.APPROVE_VERSION, self.addon, self.version) for x in range(0, 3): amo.log(amo.LOG.REJECT_VERSION, self.addon, self.version) for x in range(0, 5): amo.log(amo.LOG.APPROVE_VERSION, self.addon, self.version) dedupe_approvals([self.addon.pk]) eq_(ActivityLog.objects.for_addons(self.addon).count(), 3)
def handle(self, *args, **options): pks = Addon.objects.values_list('pk', flat=True).order_by('id') for chunk in chunked(pks, 100): dedupe_approvals(chunk)