Skip to content

Instantly share code, notes, and snippets.

@moacirmoda
Created December 11, 2018 17:52
Show Gist options
  • Save moacirmoda/9b360a9803b8f4169b47ef162a4128c8 to your computer and use it in GitHub Desktop.
Save moacirmoda/9b360a9803b8f4169b47ef162a4128c8 to your computer and use it in GitHub Desktop.
# demandas duplicadas
from api.models import *
from datetime import timedelta
ids_duplicated = []
for diligencia in Diligencia.objects.all().order_by('-id'):
if diligencia.id in ids_duplicated:
continue
user = diligencia.user
start_time = diligencia.created_at - timedelta(seconds=30)
end_time = diligencia.created_at + timedelta(seconds=30)
queryset = Diligencia.objects.filter(
user=user, created_at__gte=start_time, created_at__lte=end_time)
if queryset.count() > 1:
print queryset[0].created_at,
for i in queryset:
print i,
ids_duplicated.append(i.id)
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment