diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2020-07-22 23:06:15 +0100 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2020-07-22 23:14:10 +0100 |
commit | 070157eacbdcfa34938002ebe7b572319e0f7d24 (patch) | |
tree | abebc3953844afa76b31149e797107549e2c88a1 /parsers/imports.py | |
parent | fbf5daff0ea0f9b6b3bd19940f981dfa7c42763d (diff) | |
download | troggle-070157eacbdcfa34938002ebe7b572319e0f7d24.tar.gz troggle-070157eacbdcfa34938002ebe7b572319e0f7d24.tar.bz2 troggle-070157eacbdcfa34938002ebe7b572319e0f7d24.zip |
TRansX speedup for import + remove fossil profiles
Diffstat (limited to 'parsers/imports.py')
-rw-r--r-- | parsers/imports.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/parsers/imports.py b/parsers/imports.py index 7c83d90..5757a7b 100644 --- a/parsers/imports.py +++ b/parsers/imports.py @@ -7,6 +7,7 @@ from django.db import connection, close_old_connections, connections from django.contrib.auth.models import User from django.http import HttpResponse #from django.urls import reverse, resolve +from django.db import transaction import troggle.settings import troggle.parsers.caves @@ -19,37 +20,47 @@ import troggle.parsers.subcaves def import_caves(): print("-- Importing Caves to ",end="") print(django.db.connections.databases['default']['NAME']) - troggle.parsers.caves.readcaves() + # wrap the entire import in a transaction + with transaction.atomic(): + troggle.parsers.caves.readcaves() def import_people(): print("-- Importing People (folk.csv) to ",end="") print(django.db.connections.databases['default']['NAME']) - troggle.parsers.people.LoadPersonsExpos() + with transaction.atomic(): + troggle.parsers.people.LoadPersonsExpos() def import_surveyscans(): print("-- Importing Survey Scans") - troggle.parsers.surveys.LoadListScans() + with transaction.atomic(): + troggle.parsers.surveys.LoadListScans() def import_logbooks(): print("-- Importing Logbooks") - troggle.parsers.logbooks.LoadLogbooks() + with transaction.atomic(): + troggle.parsers.logbooks.LoadLogbooks() def import_QMs(): print("-- Importing old QMs for 161, 204, 234 from CSV files") - troggle.parsers.QMs.Load_QMs() + with transaction.atomic(): + troggle.parsers.QMs.Load_QMs() def import_survex(): # when this import is moved to the top with the rest it all crashes horribly - import troggle.parsers.survex + with transaction.atomic(): + import troggle.parsers.survex print("-- Importing Survex and Entrance Positions") print(" - Survex Blocks") - troggle.parsers.survex.LoadSurvexBlocks() + with transaction.atomic(): + troggle.parsers.survex.LoadSurvexBlocks() print(" - Survex entrances x/y/z Positions") - troggle.parsers.survex.LoadPositions() + with transaction.atomic(): + troggle.parsers.survex.LoadPositions() def import_loadpos(): # when this import is moved to the top with the rest it all crashes horribly - import troggle.parsers.survex + with transaction.atomic(): + import troggle.parsers.survex print(" - Survex entrances x/y/z Positions") troggle.parsers.survex.LoadPositions() |