Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/proposals-performance-issues…
Browse files Browse the repository at this point in the history
…-2' into feat/capistrano_deploy
  • Loading branch information
davidbeig committed Nov 26, 2024
2 parents b2695da + 08a7f17 commit 6de56f0
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 30 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ gem "decidim-stats", path: "decidim-stats"

gem "decidim-decidim_awesome", git: "https://github.com/decidim-ice/decidim-module-decidim_awesome"
gem "decidim-internal_evaluation", git: "https://github.com/AjuntamentdeBarcelona/decidim-internal-evaluation-module", branch: "release/0.28-stable"
gem "decidim-kids", git: "https://github.com/AjuntamentdeBarcelona/decidim-module-kids"
gem "decidim-navigation_maps", git: "https://github.com/Platoniq/decidim-module-navigation_maps"
gem "decidim-term_customizer", git: "https://github.com/mainio/decidim-module-term_customizer"
gem "decidim-vocdoni", git: "https://github.com/decidim-vocdoni/decidim-module-vocdoni"
Expand Down Expand Up @@ -62,7 +61,6 @@ group :production do
gem "dalli"
gem "lograge"
gem "matrix"
gem "puma_worker_killer" # Used to restart puma workers every 6h and free memory
gem "rack_password"
gem "rack-ssl-enforcer"
gem "rack-timeout" # Let's kill long-running requests after the Heroku router has responded to
Expand Down
19 changes: 1 addition & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ GIT

GIT
remote: https://github.com/AjuntamentdeBarcelona/decidim-internal-evaluation-module
revision: cf5eb7f00f957881ade8360a69655e92d95ceff0
revision: 9c656bb021c5e2ee055c9686e43c880566d4cef1
branch: release/0.28-stable
specs:
decidim-internal_evaluation (0.0.1)
Expand All @@ -190,16 +190,6 @@ GIT
decidim-templates (~> 0.28.0)
deface (~> 1.9)

GIT
remote: https://github.com/AjuntamentdeBarcelona/decidim-module-kids
revision: df16cf4de13c306348761d850d19815c8221874e
specs:
decidim-kids (0.2.0)
decidim-core (>= 0.28, < 0.29)
decidim-system (>= 0.28, < 0.29)
decidim-verifications (>= 0.28, < 0.29)
deface (>= 1.5)

GIT
remote: https://github.com/Platoniq/decidim-module-navigation_maps
revision: 7fd50e1368bae4c7955c0ba8ec5ee395273a5329
Expand Down Expand Up @@ -540,8 +530,6 @@ GEM
base64 (>= 0.1.0)
csv (>= 3.0.0)
geom2d (0.4.1)
get_process_mem (0.2.7)
ffi (~> 1.0)
globalid (1.2.1)
activesupport (>= 6.1)
graphql (2.0.31)
Expand Down Expand Up @@ -752,9 +740,6 @@ GEM
public_suffix (6.0.1)
puma (6.4.2)
nio4r (~> 2.0)
puma_worker_killer (0.3.1)
get_process_mem (~> 0.2)
puma (>= 2.7)
racc (1.8.1)
rack (2.2.10)
rack-attack (6.7.0)
Expand Down Expand Up @@ -1050,7 +1035,6 @@ DEPENDENCIES
decidim-ephemeral_participation!
decidim-initiatives!
decidim-internal_evaluation!
decidim-kids!
decidim-navigation_maps!
decidim-sortitions!
decidim-stats!
Expand All @@ -1069,7 +1053,6 @@ DEPENDENCIES
origami
progressbar
puma
puma_worker_killer
rack-ssl-enforcer
rack-timeout
rack_password
Expand Down
26 changes: 26 additions & 0 deletions app/cells/decidim/author/show.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<span class="author" data-author>
<%= content_tag :span, class: "author__container#{" is-compact" if layout == :compact}" do %>
<% if layout == :compact %>
<%= render :avatar %>

<span>
<%= render :name %>

<% context_actions.each do |action| %>
<%= render action %>
<% end %>
</span>
<% elsif layout == :avatar %>
<%= render :avatar %>
<% else %>
<%= render :avatar %>
<%= render :name %>
<% end %>
<% end %>

<% if layout == :default %>
<% context_actions.each do |action| %>
<%= render action %>
<% end %>
<% end %>
</span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div id="breadcrumb-secondary-dropdown-<%= id %>" class="menu-bar__secondary-dropdown">
<div class="menu-bar__secondary-dropdown__left">
<%= render :metadata %>
</div>
<ul class="menu-bar__secondary-dropdown__menu">
<%= render :links %>
</ul>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

module Decidim
module Proposals
module ProposalsControllerOverride
extend ActiveSupport::Concern

included do
def index
if component_settings.participatory_texts_enabled?
@proposals = Decidim::Proposals::Proposal
.where(component: current_component)
.published
.not_hidden
.only_amendables
.includes(:category, :scope, :attachments, :coauthorships)
.order(position: :asc)
render "decidim/proposals/proposals/participatory_texts/participatory_text"
else
@proposals = search
.result
.published
.not_hidden

@all_geocoded_proposals = @proposals.geocoded

@proposals = reorder(@proposals)
@proposals = paginate(@proposals)
@proposals = @proposals.includes(:component, :coauthorships, :attachments)

@voted_proposals = if current_user
ProposalVote.where(
author: current_user,
proposal: @proposals.pluck(:id)
).pluck(:decidim_proposal_id)
else
[]
end
end
end
end
end
end
end
44 changes: 44 additions & 0 deletions app/views/decidim/proposals/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<% add_decidim_page_title(t("name", scope: "decidim.components.proposals")) %>

<% append_stylesheet_pack_tag "decidim_proposals", media: "all" %>
<% append_javascript_pack_tag "decidim_proposals" %>

<% content_for :aside do %>
<h1 id="proposals-count" class="title-decorator"><%= component_name %></h1>

<div class="proposal-list__aside__button-container">
<% if current_settings.creation_enabled && current_component.participatory_space.can_participate?(current_user) %>
<%= action_authorized_link_to :create, new_proposal_path, class: "button button__xl button__secondary w-full", data: { "redirect_url" => new_proposal_path } do %>
<span><%= t("new_proposal", scope: "decidim.proposals.proposals.index") %></span>
<%= icon "add-line" %>
<% end %>
<% end %>

<% if component_settings.collaborative_drafts_enabled? %>
<%= link_to collaborative_drafts_path, class: "button button__sm button__transparent-secondary" do %>
<span><%= t("collaborative_drafts_list", scope: "decidim.proposals.proposals.index") %></span>
<%= icon "edit-2-line" %>
<% end %>
<% end %>
</div>

<%= render layout: "decidim/shared/filters", locals: { filter_sections: , search_variable: :search_text_cont, skip_to_id: "proposals" } do %>
<%= hidden_field_tag :order, order, id: nil, class: "order_filter" %>
<% end %>
<% end %>

<%= render layout: "layouts/decidim/shared/layout_two_col" do %>

<%= render partial: "decidim/shared/component_announcement" %>

<% if show_voting_rules? %>
<section class="layout-main__section">
<%= render partial: "voting_rules" %>
</section>
<% end %>

<section id="proposals" class="layout-main__section layout-main__heading">
<%= render partial: "proposals" %>
</section>

<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div id="<%= id %>" class="menu-bar__main-dropdown">
<div class="menu-bar__main-dropdown__top">
<div class="menu-bar__main-dropdown__top-left">
<%= render partial: "layouts/decidim/header/menu_breadcrumb_main_dropdown_top_left" %>
</div>
<%= breadcrumb_root_menu.render %>
</div>
<div class="menu-bar__main-dropdown__bottom">
<div class="menu-bar__main-dropdown__bottom-left">
<%= cell("decidim/highlighted_participatory_process", menu_highlighted_participatory_process) %>
</div>
</div>
</div>
5 changes: 5 additions & 0 deletions config/initializers/decidim_overrides.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

Rails.application.config.to_prepare do
default_options = Decidim::Paginable::OPTIONS
Decidim::Paginable.send(:remove_const, :OPTIONS)
Decidim::Paginable::OPTIONS = (default_options + [10]).uniq.sort.freeze

Decidim::PaginateHelper.include(Decidim::PaginateHelperOverride)
Decidim::Initiatives::Admin::Permissions.prepend(Decidim::Initiatives::Admin::PermissionsOverride)
Decidim::SearchResourceFieldsMapper.prepend(Decidim::Overrides::SearchResourceFieldsMapper)
Expand All @@ -22,4 +26,5 @@
Decidim::Forms::QuestionnaireUserAnswers.include(Decidim::Forms::QuestionnaireUserAnswersOverride)
Decidim::Proposals::ApplicationHelper.include(Decidim::Proposals::ApplicationHelperOverride)
Decidim::Assemblies::AssembliesController.include(Decidim::Assemblies::AssembliesControllerOverride)
Decidim::Proposals::ProposalsController.include(Decidim::Proposals::ProposalsControllerOverride)
end
6 changes: 0 additions & 6 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,3 @@

port ENV.fetch("PORT", nil) || 3000
environment ENV.fetch("RACK_ENV", nil) || "development"

before_fork do
require "puma_worker_killer"

PumaWorkerKiller.enable_rolling_restart
end
11 changes: 8 additions & 3 deletions spec/lib/overrides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
files: {
"/app/helpers/decidim/paginate_helper.rb" => "6fd69359386319d678c7a17cf64de4d9",
"/app/controllers/decidim/application_controller.rb" => "e86fe37834b061828536f9417fe56cd1", # ephemeral participation overrides
"/app/controllers/concerns/decidim/paginable.rb" => "a42381a0883c92df189ac61cebea3047", # update per_page method in assemblies_controller_override.rb
"/app/controllers/concerns/decidim/paginable.rb" => "a42381a0883c92df189ac61cebea3047", # update per_page method in assemblies_controller_override.rb and include 10 in OPTIONS constant
"/app/helpers/decidim/decidim_form_helper.rb" => "c534a1faa8da83aab5b2190f9d7534c3", # ephemeral participation overrides
"/app/models/decidim/component.rb" => "ec2a03817027336392f1e9e0893309ab", # ephemeral participation overrides
"/app/models/decidim/organization.rb" => "04eaf4467a1e0d891251c5cedf71f5e4", # ephemeral participation overrides
Expand All @@ -28,7 +28,10 @@
"/app/cells/decidim/activities_cell.rb" => "dd17416a8d1efe7f26b1e759613e4db4",
"/app/cells/decidim/user_profile_cell.rb" => "71216a17c7eea8dd8ebc1ea3907efaef",
"/lib/decidim/search_resource_fields_mapper.rb" => "ff2cc476eb72c2942cf2e69ae21b84fa",
"/app/views/layouts/decidim/header/_main.html.erb" => "a6496ec11e073062743a927ee3c8bd3c"
"/app/views/layouts/decidim/header/_main.html.erb" => "a6496ec11e073062743a927ee3c8bd3c",
"/app/cells/decidim/participatory_space_dropdown_metadata/show.erb" => "e1546b7776a0e1fffdbef705094c189d", # delete last activity
"/app/cells/decidim/author/show.erb" => "20bdef8a694a2dcb70202ac7f017060d", # remove tooltip
"/app/views/layouts/decidim/header/_menu_breadcrumb_main_dropdown.html.erb" => "494b33a9fc70f859f766962815399445" # delete last activity
}
},
{
Expand Down Expand Up @@ -114,8 +117,10 @@
{
package: "decidim-proposals",
files: {
"/app/controllers/decidim/proposals/proposals_controller.rb" => "69420e7f27e1e7cb2688dadcc91017b3",
"/app/helpers/decidim/proposals/application_helper.rb" => "c17dd875a166cd0cd3c09b0e596ebef5",
"/app/presenters/decidim/proposals/proposal_presenter.rb" => "bbc7cee02125c1f8cf909219e48af337"
"/app/presenters/decidim/proposals/proposal_presenter.rb" => "bbc7cee02125c1f8cf909219e48af337",
"/app/views/decidim/proposals/proposals/index.html.erb" => "48b62ae409b6ed736375772946ef2aa9" # remove map from index page
}
},
{
Expand Down
1 change: 0 additions & 1 deletion spec/system/assemblies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

it "lists 25 assemblies per page" do
within "#assemblies-grid" do
expect(page).to have_content("Results per page:\n25")
expect(page).to have_css("[id^=assembly_]", count: 25)
end
end
Expand Down

0 comments on commit 6de56f0

Please sign in to comment.