changeset 4292:18a34d9b289c

data availability layer: loader uses new cache
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 30 Aug 2019 12:36:27 +0200
parents 81ab34bd2d0d
children dbd8d2416da7
files client/src/components/map/layers.js client/src/store/gauges.js
diffstat 2 files changed, 8 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/map/layers.js	Fri Aug 30 12:11:35 2019 +0200
+++ b/client/src/components/map/layers.js	Fri Aug 30 12:36:27 2019 +0200
@@ -546,28 +546,14 @@
 
                 // attach nsc data to gauge
                 if (f.getId().indexOf("gauges") > -1) {
-                  // look for nashSutcliffeOverview in store. If present and
-                  // not older than 15 min use it or fetch new data and store it.
-                  let data = store.getters["gauges/nashSutcliffeOverview"](f);
-                  if (
-                    data &&
-                    new Date().getTime() - data.createdAt.getTime() < 900000
-                  ) {
-                    f.set("nsc_data", data.data);
-                  } else {
-                    data = await store.dispatch(
-                      "gauges/loadNashSutcliffeForOverview",
+                  store
+                    .dispatch(
+                      "gauges/getNashSutcliffeForISRS",
                       f.get("isrs_code")
-                    );
-                    if (data) {
-                      store.commit("gauges/addNashSutcliffeOverviewEntry", {
-                        feature: f,
-                        data,
-                        createdAt: new Date()
-                      });
-                      f.set("nsc_data", data);
-                    }
-                  }
+                    )
+                    .then(response => {
+                      f.set("nsc_data", response);
+                    });
                 }
               }
             )
--- a/client/src/store/gauges.js	Fri Aug 30 12:11:35 2019 +0200
+++ b/client/src/store/gauges.js	Fri Aug 30 12:36:27 2019 +0200
@@ -38,7 +38,6 @@
     longtermInterval: [],
     yearWaterlevels: [],
     nashSutcliffe: null,
-    nashSutcliffeOverview: [],
     nashSutcliffeCache: {},
     dateFrom: dateFrom,
     dateTo: dateTo,
@@ -55,11 +54,6 @@
       return state.gauges.find(
         g => g.properties.isrs_code === state.selectedGaugeISRS
       );
-    },
-    nashSutcliffeOverview: state => feature => {
-      return state.nashSutcliffeOverview.find(
-        d => d.feature.get("id") === feature.get("id")
-      );
     }
   },
   mutations: {
@@ -95,15 +89,7 @@
       state.nashSutcliffe = data;
     },
     deleteNashSutcliffeCache: state => {
-      state.nashSutcliffeOverview = [];
-    },
-    addNashSutcliffeOverviewEntry: (state, data) => {
-      let existingIndex = state.nashSutcliffeOverview.findIndex(
-        d => d.feature.get("id") === data.feature.get("id")
-      );
-      if (existingIndex !== -1)
-        state.nashSutcliffeOverview.splice(existingIndex, 1);
-      state.nashSutcliffeOverview.push(data);
+      state.nashSutcliffeCache = {};
     },
     dateFrom: (state, dateFrom) => {
       state.dateFrom = dateFrom;