From 78064481db2c4647388e3ccd5708005a6cc86044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80=20=D0=93=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=BA=D0=B8=D1=85?= Date: Thu, 14 Nov 2019 10:53:19 +0300 Subject: [PATCH] Award migrate add tqdm --- apps/main/management/commands/add_award.py | 3 ++- apps/main/management/commands/add_award_type.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/main/management/commands/add_award.py b/apps/main/management/commands/add_award.py index 85a613cf..b7abd20d 100644 --- a/apps/main/management/commands/add_award.py +++ b/apps/main/management/commands/add_award.py @@ -3,6 +3,7 @@ from django.db import connections from establishment.management.commands.add_position import namedtuplefetchall from main.models import Award, AwardType from establishment.models import Employee +from tqdm import tqdm class Command(BaseCommand): @@ -25,7 +26,7 @@ class Command(BaseCommand): def handle(self, *args, **kwargs): objects =[] - for a in self.award_sql(): + for a in tqdm(self.award_sql(), desc='Add award to profile'): profile = Employee.objects.filter(old_id=a.profile_id).first() type = AwardType.objects.filter(old_id=a.award_type).first() state = Award.PUBLISHED if a.state == 'published' else Award.WAITING diff --git a/apps/main/management/commands/add_award_type.py b/apps/main/management/commands/add_award_type.py index 63aa6546..eb693ad2 100644 --- a/apps/main/management/commands/add_award_type.py +++ b/apps/main/management/commands/add_award_type.py @@ -3,7 +3,7 @@ from django.db import connections from establishment.management.commands.add_position import namedtuplefetchall from main.models import AwardType from location.models import Country - +from tqdm import tqdm class Command(BaseCommand): help = '''Add award types from old db to new db. @@ -24,7 +24,7 @@ class Command(BaseCommand): def handle(self, *args, **kwargs): objects =[] - for a in self.award_types_sql(): + for a in tqdm(self.award_types_sql(), desc='Add award types: '): country = Country.objects.filter(code=a.country_code).first() if country: type = AwardType(name=a.name, old_id=a.id)