Skip to content

Commit

Permalink
Merge pull request #1557 from MetaPhase-Consulting/update/reference-c…
Browse files Browse the repository at this point in the history
…ache

Cache reference data for 2 minutes
  • Loading branch information
mjoyce91 committed Jun 21, 2021
2 parents 3882732 + 6ef29ec commit 3c1e571
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/actions/filters/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ export function filtersFetchData(items = { filters: [] }, queryParams = {}, save
|| item.selectionRef === ENDPOINT_PARAMS.postAP) {
dispatch(filtersIsLoading(true));
const endpoint = '/fsbid/reference/locations/';
return api().get(endpoint)
return api().get(endpoint, {
cache: {
maxAge: 2 * 60 * 1000, // 2 min
exclude: { query: false },
},
})
.then((response) => {
// TODO - this is dummy logic to get a single location,
// since there is no fsbid endpoint to do so. Once that exists,
Expand Down Expand Up @@ -279,7 +284,12 @@ export function filtersFetchData(items = { filters: [] }, queryParams = {}, save
const endpointResponses = {};

const uniqueEndpoints = uniqBy(dynamicFilters, 'item.endpoint').map(m => m.item.endpoint);
const uniqueFilters = uniqueEndpoints.map(m => api().get(`/${m}`).then(res => {
const uniqueFilters = uniqueEndpoints.map(m => api().get(`/${m}`, {
cache: {
maxAge: 2 * 60 * 1000, // 2 min
exclude: { query: false },
},
}).then(res => {
endpointResponses[m] = res;
return res;
})
Expand Down

0 comments on commit 3c1e571

Please sign in to comment.