add heavy caching to mapdata api
This commit is contained in:
parent
23da7e3605
commit
00193f7e11
22 changed files with 259 additions and 138 deletions
|
@ -4,6 +4,8 @@ from django.db import models
|
|||
from django.db.models.base import ModelBase
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.mapdata.lastupdate import set_last_mapdata_update
|
||||
|
||||
MAPITEM_TYPES = OrderedDict()
|
||||
|
||||
|
||||
|
@ -40,5 +42,9 @@ class MapItem(models.Model, metaclass=MapItemMeta):
|
|||
def tofile(self):
|
||||
return OrderedDict()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
with set_last_mapdata_update():
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -8,7 +8,7 @@ from shapely.geometry.geo import mapping, shape
|
|||
from c3nav.mapdata.fields import GeometryField
|
||||
from c3nav.mapdata.models import Elevator
|
||||
from c3nav.mapdata.models.base import MapItem, MapItemMeta
|
||||
from c3nav.mapdata.utils import format_geojson
|
||||
from c3nav.mapdata.utils.json import format_geojson
|
||||
|
||||
GEOMETRY_MAPITEM_TYPES = OrderedDict()
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ from django.conf import settings
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from c3nav.mapdata.lastupdate import set_last_mapdata_update
|
||||
|
||||
|
||||
class Package(models.Model):
|
||||
"""
|
||||
|
@ -93,5 +95,9 @@ class Package(models.Model):
|
|||
|
||||
return data
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
with set_last_mapdata_update():
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue