add heavy caching to mapdata api
This commit is contained in:
parent
23da7e3605
commit
00193f7e11
22 changed files with 259 additions and 138 deletions
11
src/c3nav/mapdata/management/commands/clearmapcache.py
Normal file
11
src/c3nav/mapdata/management/commands/clearmapcache.py
Normal 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
|
|
@ -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.')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue