Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache reference data for 2 minutes #1557

Merged
merged 2 commits into from
Jun 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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