send update_cache_key a different way

This commit is contained in:
Laura Klünder 2019-12-10 12:37:33 +01:00
parent 7431bac30a
commit dce93c3dd0
3 changed files with 10 additions and 7 deletions

View file

@ -320,10 +320,10 @@ class EditorViewSet(EditorViewSetMixin, ViewSet):
else: else:
raise ValidationError('No level or space specified.') raise ValidationError('No level or space specified.')
return Response({ return Response(list(chain(
'update_cache_key': update_cache_key, [('update_cache_key', update_cache_key)],
'geometries': [self.conditional_geojson(obj, update_cache_key_match) for obj in results], (self.conditional_geojson(obj, update_cache_key_match) for obj in results)
}) )))
def conditional_geojson(self, obj, update_cache_key_match): def conditional_geojson(self, obj, update_cache_key_match):
if update_cache_key_match and not obj._affected_by_changeset: if update_cache_key_match and not obj._affected_by_changeset:

View file

@ -698,9 +698,13 @@ editor = {
$.getJSON(geometry_url, function(result) { $.getJSON(geometry_url, function(result) {
var geometries = [], feature, new_cache = {}, feature_type, feature_id; var geometries = [], feature, new_cache = {}, feature_type, feature_id;
// geometries cache logic // geometries cache logic
for (var i=0;i<result.geometries.length;i++) { for (var i=0;i<result.length;i++) {
feature = result.geometries[i]; feature = result[i];
if (Array.isArray(feature)) { if (Array.isArray(feature)) {
if (feature[0] === 'update_cache_key') {
editor._last_geometry_update_cache_key = feature[1];
continue;
}
// load from cache // load from cache
if (feature[0] in editor._last_geometry_cache) { if (feature[0] in editor._last_geometry_cache) {
feature = editor._last_geometry_cache[feature[0]][feature[1]]; feature = editor._last_geometry_cache[feature[0]][feature[1]];
@ -722,7 +726,6 @@ editor = {
geometries.push(feature); geometries.push(feature);
} }
editor._last_geometry_cache = new_cache; editor._last_geometry_cache = new_cache;
editor._last_geometry_update_cache_key = result.update_cache_key;
editor.map.removeLayer(editor._highlight_layer); editor.map.removeLayer(editor._highlight_layer);
editor._highlight_layer.clearLayers(); editor._highlight_layer.clearLayers();

0
src/c3nav/profiler.py Normal file
View file