Commit a1f871c8 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add user of iterator on queryset

parent 9c3c0fa8
......@@ -24,10 +24,8 @@ class Command(BaseCommand):
def handle(self, *args, **options):
answered_actions_ids = Action.objects.filter(verb='answered').values_list('action_object_object_id', flat=True)
counter = 0
# Create any missing Answer action
answers = Answer.objects.all()
answers = Answer.objects.all().iterator()
for answer in answers:
activity_id = answer.activity_id
......@@ -35,6 +33,7 @@ class Command(BaseCommand):
verb = 'answered'
if str(answer.id) in answered_actions_ids:
print('Skipped for answer id:', answer.id)
continue
timesince = djtimesince(answer.timestamp).encode('utf8').replace(b'\xc2\xa0', b' ').decode('utf8')
......@@ -43,3 +42,5 @@ class Command(BaseCommand):
action_obj = action_tuple[0][1]
action_obj.timestamp = answer.timestamp
action_obj.save()
print("Creating action for answer id:", answer.id)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment