add heavy caching to mapdata api

This commit is contained in:
Laura Klünder 2016-12-07 16:11:33 +01:00
parent 23da7e3605
commit 00193f7e11
22 changed files with 259 additions and 138 deletions

View file

@ -0,0 +1,11 @@
from django.core.management.base import BaseCommand
from c3nav.mapdata.lastupdate import set_last_mapdata_update
class Command(BaseCommand):
help = 'Clear the map cache (set last updated to now)'
def handle(self, *args, **options):
with set_last_mapdata_update():
pass

View file

@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from c3nav.mapdata.lastupdate import set_last_mapdata_update
from c3nav.mapdata.packageio import MapdataReader
@ -15,8 +16,9 @@ class Command(BaseCommand):
reader = MapdataReader()
reader.read_packages()
with transaction.atomic():
reader.apply_to_db()
print()
if not options['yes'] and input('Confirm (y/N): ') != 'y':
raise CommandError('Aborted.')
with set_last_mapdata_update():
with transaction.atomic():
reader.apply_to_db()
print()
if not options['yes'] and input('Confirm (y/N): ') != 'y':
raise CommandError('Aborted.')