From 257576afc1cb02f1b2e0ae3a258175991b9c87fd Mon Sep 17 00:00:00 2001 From: Alexandru Emil Lupu Date: Thu, 9 Jan 2025 13:49:01 +0200 Subject: [PATCH] Fix proposal map performance with hundreds of markers (#13798) * Fix proposal map * Remove unusued meeting script * Fix test * linters * Revert "Remove unusued meeting script" This reverts commit ea977f27394e96922dde91504e3a0cb1aedf8761. * Manual revert --- .../decidim/proposals/proposals_controller.rb | 2 -- .../app/helpers/decidim/proposals/map_helper.rb | 2 +- .../views/decidim/proposals/proposals/index.html.erb | 2 +- .../views/decidim/proposals/proposals/index.js.erb | 12 ++++++++++++ .../decidim/proposals/proposals_controller_spec.rb | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb b/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb index 76fff1187cb4a..3a86691356d50 100644 --- a/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +++ b/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb @@ -45,8 +45,6 @@ def index else @proposals = search.result - @all_geocoded_proposals = @proposals.geocoded if Decidim::Map.available?(:geocoding, :dynamic) && component_settings.geocoding_enabled? - @proposals = reorder(@proposals) @proposals = paginate(@proposals) @proposals = @proposals.includes(:component, :coauthorships, :attachments) diff --git a/decidim-proposals/app/helpers/decidim/proposals/map_helper.rb b/decidim-proposals/app/helpers/decidim/proposals/map_helper.rb index 0b165700a07ab..623ab6be480e4 100644 --- a/decidim-proposals/app/helpers/decidim/proposals/map_helper.rb +++ b/decidim-proposals/app/helpers/decidim/proposals/map_helper.rb @@ -9,7 +9,7 @@ module MapHelper # # geocoded_proposals - A collection of geocoded proposals def proposals_data_for_map(geocoded_proposals) - geocoded_proposals.map do |proposal| + geocoded_proposals.select(&:geocoded_and_valid?).map do |proposal| proposal_data_for_map(proposal) end end diff --git a/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb b/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb index 5f30111b6ea01..b368e41f5a583 100644 --- a/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +++ b/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb @@ -35,7 +35,7 @@ <% if Decidim::Map.available?(:geocoding, :dynamic) && component_settings.geocoding_enabled? %>
- <%= dynamic_map_for proposals_data_for_map(@all_geocoded_proposals) do %> + <%= dynamic_map_for proposals_data_for_map(@proposals) do %>