From 648bca247a6328f9214963c5adfbef928ec37f00 Mon Sep 17 00:00:00 2001 From: Romina Date: Mon, 16 Nov 2020 17:01:29 -0300 Subject: [PATCH 1/3] fix(MapView stats): use the stats endpoint instead of counting the geojson entries since we can get the same info --- .../posts/views/post-view-map.directive.js | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/app/main/posts/views/post-view-map.directive.js b/app/main/posts/views/post-view-map.directive.js index 92c8dbf692..1f5793520e 100644 --- a/app/main/posts/views/post-view-map.directive.js +++ b/app/main/posts/views/post-view-map.directive.js @@ -144,11 +144,37 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com function getStats () { // Getting stats for filter-dropdown - let def = PostFilters.getQueryParams(PostFilters.getDefaults()); - PostEndpoint.geojson(def).$promise.then(res => { - $scope.stats.totalItems = res.features.length; - $scope.stats.unmapped = res.total - res.features.length; + getPostStats(PostFilters.getDefaults()).$promise.then(function (result) { + $scope.stats.totalItems = result.totals[0].values.reduce( + function (a,b) { + return a.total + b.total + } + ); + + $scope.stats.unmapped = result.unmapped; + }); + } + + function getPostStats(filters) { + var query = PostFilters.getQueryParams(filters); + var queryParams = _.extend({}, query, { + include_unmapped: true, + status: 'all' }); + + // we don't want a group_by or filter + if (queryParams.form) { + delete queryParams.form; + } + if (queryParams.group_by) { + delete queryParams.group_by; + } + + // deleting source, we want stats for all datasources to keep the datasource-bucket-stats unaffected by data-source-filters + if (queryParams.source) { + delete queryParams.source; + } + return PostEndpoint.stats(queryParams); } function loadPosts(query) { From 6e0b49acaed7d8bacfc594529da9987e6d77720a Mon Sep 17 00:00:00 2001 From: Anna Date: Tue, 17 Nov 2020 13:22:17 +0100 Subject: [PATCH 2/3] Fixing broken datepicker in filter-dropdown #4169 --- app/main/posts/views/filters/filter-date.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/main/posts/views/filters/filter-date.html b/app/main/posts/views/filters/filter-date.html index 6271a5524c..bec6b7069f 100644 --- a/app/main/posts/views/filters/filter-date.html +++ b/app/main/posts/views/filters/filter-date.html @@ -1,24 +1,25 @@
- +
- +
+
to
- +
- +
From 194375d75093a6aea34ffccb3c4f2af9e0e212a5 Mon Sep 17 00:00:00 2001 From: Romina Date: Tue, 17 Nov 2020 09:38:34 -0300 Subject: [PATCH 3/3] fix(MapView totals): total items is the total of mapped items, not the total of all items --- app/main/posts/views/post-view-map.directive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/main/posts/views/post-view-map.directive.js b/app/main/posts/views/post-view-map.directive.js index 1f5793520e..7365329bef 100644 --- a/app/main/posts/views/post-view-map.directive.js +++ b/app/main/posts/views/post-view-map.directive.js @@ -149,7 +149,7 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com function (a,b) { return a.total + b.total } - ); + ) - result.unmapped; $scope.stats.unmapped = result.unmapped; });