From 5af336fff319179199b185e2def194bdf5fbb67f Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Tue, 26 May 2020 23:53:13 +0200 Subject: [PATCH] make things cleaner --- management/commands/_import_utils.py | 2 +- management/commands/import_activities.py | 2 +- management/commands/import_nk15.py | 2 +- shell/tabularasa | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/management/commands/_import_utils.py b/management/commands/_import_utils.py index 3903820..dfd9f4a 100644 --- a/management/commands/_import_utils.py +++ b/management/commands/_import_utils.py @@ -19,7 +19,7 @@ def timed(method): ts = time.time() result = method(*args, **kw) te = time.time() - args[0].print_success(f"{method.__name__} executed ({te-ts:.2f}s)") + args[0].print_success(f"\n {method.__name__} executed ({te-ts:.2f}s)") return result return _timed diff --git a/management/commands/import_activities.py b/management/commands/import_activities.py index 840da02..e4fd7f8 100644 --- a/management/commands/import_activities.py +++ b/management/commands/import_activities.py @@ -58,7 +58,7 @@ class Command(ImportCommand): } # WARNING: Fields lieu, liste, listeimprimee are missing MAP_ACTIVITY[row["id"]] = pk_activity - pk_activity +=1 + pk_activity += 1 bulk_mgr.add(Activity(**obj_dict)) bulk_mgr.done() diff --git a/management/commands/import_nk15.py b/management/commands/import_nk15.py index 629b5f7..b0a8236 100644 --- a/management/commands/import_nk15.py +++ b/management/commands/import_nk15.py @@ -14,5 +14,5 @@ class Command(BaseCommand): subprocess.call("./apps/scripts/shell/tabularasa") call_command('import_account', alias=True, chunk=1000, save = "map.json") call_command('import_activities', chunk=100, map="map.json") - call_command('import_transaction', buttons=True, map="map.json") + call_command('import_transaction', chunk=10000, buttons=True, map="map.json") # diff --git a/shell/tabularasa b/shell/tabularasa index 6bc837d..0a81c5f 100755 --- a/shell/tabularasa +++ b/shell/tabularasa @@ -1,6 +1,7 @@ #!/usr/bin/sh sudo -u postgres sh -c "dropdb note_db && psql -c 'CREATE DATABASE note_db OWNER note;'"; echo 'reset db'; -source "env/bin/activate" +find apps/ -path "*/migrations/*.py*" -not -name "__init__.py" -delete +./manage.py makemigrations ./manage.py migrate ./manage.py loaddata initial