diff --git a/app/controllers/digests_controller.rb b/app/controllers/digests_controller.rb index ae0f0a2995e237d5c2e35484fbe6686ac7ed51dd..b003d346c4b4e30c4a3e397624c5899fbdd5e0bc 100644 --- a/app/controllers/digests_controller.rb +++ b/app/controllers/digests_controller.rb @@ -2,7 +2,6 @@ class DigestsController < ApplicationController has_scope :region, :locality, :tag has_scope :near, type: :hash, using: %i[location distance] - has_scope :moderated, default: nil, allow_blank: true has_scope :period, allow_blank: true, type: :hash, using: %i[year week], default: ( lambda do @@ -28,6 +27,6 @@ class DigestsController < ApplicationController def set_events @week ||= Time.zone.today + 7.days - @events = apply_scopes Event + @events = apply_scopes Event.moderated end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 34769bc62b89e247d865a740c5818381e520635b..81f476043442b4aa6f813b3f5adabfe2a373cb49 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -2,6 +2,7 @@ class TagsController < InheritedResources::Base has_scope :region, :locality, :daylimit has_scope :tag, as: :id + before_action :set_orgas, if: -> { params[:id].present? } def index @tags = ActsAsTaggableOn::Tag.where('taggings_count > ?', @@ -21,7 +22,6 @@ class TagsController < InheritedResources::Base def show @events_future = apply_scopes Event.moderated.future @events_past = apply_scopes Event.moderated.past - @orgas = apply_scopes Orga.moderated.active respond_to do |format| format.html @@ -29,23 +29,16 @@ class TagsController < InheritedResources::Base end end - def orgas - @tags = organise_tags apply_scopes(Orga.moderated) - - respond_to do |format| - format.html - format.json { render json: @tags } - end - end - private # Splits, groups, rejects the less used - def organise_tags(tags) - tags.where.not(tags: '').pluck(:tags).map(&:split).flatten - .group_by { |i| i } - .map { |k, v| [k, v.size] } - .reject { |_k, v| v <= 3 } - .sort { |t| -t[1] } + def set_orgas + @orgas = (apply_scopes(Orga.moderated.active) + + Orga.moderated.active + .where( + 'lower(name) like lower(?)', + "%#{params[:id].tr '-', '%'}%" + ) + ).uniq end end diff --git a/config/application.rb b/config/application.rb index 9fb323bc0541743c7becddf6eea1319953ec3df8..46f04399803b9bd0f60a4defe42f9ced97ff53ee 100644 --- a/config/application.rb +++ b/config/application.rb @@ -49,6 +49,6 @@ module AgendaDuLibreRails # TODO config.action_controller.per_form_csrf_tokens = false - config.cloud_threshold = 3 + config.cloud_threshold = 5 end end