📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix bug with log pid and cache redux for custom range
kruzhambusf79563ae0cde
diff --git a/src/pages/Project/View/ViewProject.container.jsx b/src/pages/Project/View/ViewProject.container.jsxindex d1f7313c4..29fcb9a28 100644--- a/src/pages/Project/View/ViewProject.container.jsx+++ b/src/pages/Project/View/ViewProject.container.jsx@@ -16,8 +16,8 @@ const mapDispatchToProps = (dispatch) => ({showError: (message) => {dispatch(errorsActions.genericError(message))},- setProjectCache: (pid, period, timeBucket, data) => {- dispatch(UIActions.setProjectCache(pid, period, timeBucket, data))+ setProjectCache: (pid, period, timeBucket, data, key) => {+ dispatch(UIActions.setProjectCache(pid, period, timeBucket, data, key))},setProjectViewPrefs: (pid, period, timeBucket, rangeDate) => {dispatch(UIActions.setProjectViewPrefs(pid, period, timeBucket, rangeDate))diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex 661a47c5c..95ebdbaa4 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -315,19 +315,27 @@ const ViewProject = ({setDataLoading(true)try {let data- const key = getProjectCacheKey(period, timeBucket)+ let key = getProjectCacheKey(period, timeBucket)++ let from+ let to++ if (rangeDate) {+ from = getFormatDate(rangeDate[0])+ to = getFormatDate(rangeDate[1])+ key = `${from}-${to}-${timeBucket}`+ }if (!forced && !_isEmpty(cache[id]) && !_isEmpty(cache[id][key])) {data = cache[id][key]} else {if (rangeDate) {- const from = getFormatDate(rangeDate[0])- const to = getFormatDate(rangeDate[1])data = await getProjectData(id, timeBucket, '', newFilters || filters, from, to, timezone)} else {data = await getProjectData(id, timeBucket, period, newFilters || filters, '', '', timezone)}- setProjectCache(id, period, timeBucket, data || {})++ setProjectCache(id, period, timeBucket, data || {}, key)}if (_isEmpty(data)) {@@ -419,11 +427,7 @@ const ViewProject = ({}, [isLoading, showTotal, chartData, mainChart, t])useEffect(() => {- if (period !== 'custom') {- loadAnalytics()- } else if (timeBucket !== 'custom') {- loadAnalytics(true)- }+ loadAnalytics()}, [project, period, timeBucket, periodPairs, t]) // eslint-disable-lineuseEffect(() => {diff --git a/src/redux/actions/ui/index.js b/src/redux/actions/ui/index.jsindex 0b5eef076..c50e12dbe 100644--- a/src/redux/actions/ui/index.js+++ b/src/redux/actions/ui/index.js@@ -67,10 +67,10 @@ const setProjectsLoading = (isLoading) => ({},})-const setProjectCache = (pid, period, timeBucket, data) => ({+const setProjectCache = (pid, period, timeBucket, data, key) => ({type: types.SET_PROJECT_CACHE,payload: {- pid, period, timeBucket, data,+ pid, period, timeBucket, data, key},})diff --git a/src/redux/reducers/ui/cache.js b/src/redux/reducers/ui/cache.jsindex 65d0fd9bf..acec81476 100644--- a/src/redux/reducers/ui/cache.js+++ b/src/redux/reducers/ui/cache.js@@ -33,14 +33,12 @@ const getInitialState = () => {const cacheReducer = (state = getInitialState(), { type, payload }) => {switch (type) {case types.SET_PROJECT_CACHE: {- const { pid, period, timeBucket, data } = payload+ const { pid, period, timeBucket, data, key } = payload// temporarily do not store custom date ranges in cache- if (period === 'custom') {- return state- }-- const key = getProjectCacheKey(period, timeBucket)+ // if (period === 'custom') {+ // return state+ // }return {...state,