Created
December 11, 2018 17:52
-
-
Save moacirmoda/9b360a9803b8f4169b47ef162a4128c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment