Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix listReport making too many requests

Uku Taht8fccb4c353a0
diff --git a/assets/js/dashboard/stats/locations/index.js b/assets/js/dashboard/stats/locations/index.js
index 216cf37e49..31b3cc0cb7 100644
--- a/assets/js/dashboard/stats/locations/index.js
+++ b/assets/js/dashboard/stats/locations/index.js
@@ -34,7 +34,7 @@ function Countries({query, site, onClick}) {
function Regions({query, site, onClick}) {
function fetchData() {
- return api.get(apiPath(site, '/regions'), query, {country_name: query.filters.country, limit: 9})
+ return api.get(apiPath(site, '/regions'), query, {limit: 9})
}
function renderIcon(region) {
diff --git a/assets/js/dashboard/stats/reports/list.js b/assets/js/dashboard/stats/reports/list.js
index 4888a1d48b..767fba1fdb 100644
--- a/assets/js/dashboard/stats/reports/list.js
+++ b/assets/js/dashboard/stats/reports/list.js
@@ -30,11 +30,11 @@ export default function ListReport(props) {
const [state, setState] = useState({loading: true, list: null})
const valueKey = props.valueKey || 'visitors'
const showConversionRate = !!props.query.filters.goal
- const prevProps = useRef();
+ const prevQuery = useRef();
function fetchData() {
- if (typeof(prevProps.current) === 'undefined' || prevProps.current !== props) {
- prevProps.current = props;
+ if (typeof(prevQuery.current) === 'undefined' || prevQuery.current !== props.query) {
+ prevQuery.current = props.query;
setState({loading: true, list: null})
props.fetchData()
.then((res) => setState({loading: false, list: res}))