From 79720f5ddd9957d46dc81441da544d2009ab58cf Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Mon, 1 Dec 2025 15:18:07 -0500 Subject: [PATCH 01/11] AO3-7188 Allow sorting collections by number of works and by number of bookmarked items --- app/controllers/collections_controller.rb | 6 +-- app/models/search/collection_indexer.rb | 6 ++- app/models/search/collection_query.rb | 8 ++++ app/models/search/collection_search_form.rb | 7 ++- .../collections/collection_browse.feature | 46 +++++++++++++++++++ spec/models/search/collection_query_spec.rb | 10 ++++ 6 files changed, 77 insertions(+), 6 deletions(-) diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 0877f89f6cf..27999e27079 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -38,19 +38,19 @@ def index .paginate(page: params[:page]) elsif params[:collection_id] @collection = Collection.find_by!(name: params[:collection_id]) - @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page])) + @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in=logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = t(".subcollections_page_title", collection_title: @collection.title) elsif params[:user_id] @user = User.find_by!(login: params[:user_id]) - @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page])) + @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in=logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = ts("%{username} - Collections", username: @user.login) else @sort_and_filter = true - @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page])) + @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) end diff --git a/app/models/search/collection_indexer.rb b/app/models/search/collection_indexer.rb index dfe1171880e..0c2d24eb465 100644 --- a/app/models/search/collection_indexer.rb +++ b/app/models/search/collection_indexer.rb @@ -47,7 +47,11 @@ def self.mapping null_value: "NULL" }, name: { type: "text", analyzer: "simple" }, - description: { type: "text", analyzer: "standard" } + description: { type: "text", analyzer: "standard" }, + general_works_count: { type: "long" }, + public_works_count: { type: "long" }, + general_bookmarked_items_count: { type: "long" }, + public_bookmarked_items_count: { type: "long" } } } end diff --git a/app/models/search/collection_query.rb b/app/models/search/collection_query.rb index 61792360dad..d624f018235 100644 --- a/app/models/search/collection_query.rb +++ b/app/models/search/collection_query.rb @@ -1,5 +1,8 @@ +require 'devise/controllers/helpers' + class CollectionQuery < Query include TaggableQuery + include Devise::Controllers::Helpers # The "klass" function in the query classes is used only to determine what # type of search results to return (that is, which class the QueryResult @@ -126,6 +129,11 @@ def sort_column end def sort + if @user.present? || options[:admin_logged_in] + if sort_column.include?("public") + options[:sort_column] = sort_column.sub("public", "general") + end + end direction = options[:sort_direction].presence direction ||= if sort_column.include?("title") || sort_column.include?("signups_close_at") "asc" diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index 7dd45aadf29..3a5c83336b1 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -25,8 +25,9 @@ class CollectionSearchForm define_method(filterable) { options[filterable] } end - def initialize(opts = {}) + def initialize(opts = {}, admin_logged_in = false) @options = opts + @options[:admin_logged_in] = admin_logged_in process_options @searcher = CollectionQuery.new(@options) end @@ -64,7 +65,9 @@ def sort_direction def sort_options [ ["Date Created", "created_at"], - ["Title", "title.keyword"] + ["Title", "title.keyword"], + ["Bookmarked Items", "public_bookmarked_items_count"], + ["Works", "public_works_count"] ].freeze end diff --git a/features/collections/collection_browse.feature b/features/collections/collection_browse.feature index 223fdbe13e2..8e6aef1e31b 100644 --- a/features/collections/collection_browse.feature +++ b/features/collections/collection_browse.feature @@ -229,6 +229,52 @@ Feature: Collection And I should see "Surprise Presents" But I should not see "Another Gift Swap" + Scenario: Sort collections by Works and Bookmarks + + Given I have a collection "Privates" + And I have a collection "Publics" + When I am logged in as the owner of "Privates" + And I post the work "Private 1" in the collection "Privates" + And I lock the work "Private 1" + And I post the work "Private 2" in the collection "Privates" + And I lock the work "Private 2" + And I bookmark the work "Private 1" to the collection "Publics" + And I bookmark the work "Private 2" to the collection "Publics" + And I post the work "Public 1" in the collection "Publics" + And I bookmark the work "Public 1" to the collection "Privates" + And all indexing jobs have been run + And I go to the collections page + And I select "Works" from "collection_search_sort_column" + And I press "Sort and Filter" + Then I should see the text with tags '2' + And I should see the text with tags '1' + When I log out + Then I should see the text with tags '0' + And I should see the text with tags '1' + When I am logged in as a super admin + And I go to the collections page + And I select "Works" from "collection_search_sort_column" + And I press "Sort and Filter" + Then I should see the text with tags '2' + And I should see the text with tags '1' + When I go to the collections page + And I select "Bookmarked Items" from "collection_search_sort_column" + And I press "Sort and Filter" + Then I should see the text with tags '1' + And I should see the text with tags '2' + When I log out + And I go to the collections page + And I select "Bookmarked Items" from "collection_search_sort_column" + And I press "Sort and Filter" + Then I should see the text with tags '1' + And I should not see the text with tags '2' + When I am logged in as a super admin + And I go to the collections page + And I select "Bookmarked Items" from "collection_search_sort_column" + And I press "Sort and Filter" + Then I should see the text with tags '1' + And I should see the text with tags '2' + Scenario: Look at a collection, see the rules and intro and FAQ Given a set of collections for searching diff --git a/spec/models/search/collection_query_spec.rb b/spec/models/search/collection_query_spec.rb index 0220422822b..2d7bdb0fb18 100644 --- a/spec/models/search/collection_query_spec.rb +++ b/spec/models/search/collection_query_spec.rb @@ -19,6 +19,16 @@ expect(q.generated_query[:sort]).to eq([{ "title.keyword" => { order: "desc" } }, { "id" => { order: "desc" } }]) end + it 'sorts by bookmarked items' do + q = CollectionQuery.new(sort_column: "public_bookmarked_items_count", sort_direction: "desc") + expect(q.generated_query[:sort]).to eq([{ "public_bookmarkd_items_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) + end + + it 'sorts by works' do + q = CollectionQuery.new(sort_column: "public_works_count", sort_direction: "desc") + expect(q.generated_query[:sort]).to eq([{ "public_works_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) + end + describe "filtering", collection_search: true do let!(:gift_exchange) { create(:gift_exchange, signup_open: true, signups_open_at: Time.current - 2.days, signups_close_at: Time.current + 1.week) } let!(:gift_exchange_collection) { create(:collection, challenge: gift_exchange, challenge_type: "GiftExchange") } From 636b6a1775c2b612ab53924bdbd6353de3d5bb22 Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Mon, 1 Dec 2025 15:27:39 -0500 Subject: [PATCH 02/11] AO3-7188 Add rspec test --- .../collections_controller_spec.rb | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/controllers/collections_controller_spec.rb b/spec/controllers/collections_controller_spec.rb index fe38dc191eb..e5f476cf1c1 100644 --- a/spec/controllers/collections_controller_spec.rb +++ b/spec/controllers/collections_controller_spec.rb @@ -109,6 +109,38 @@ expect(response).to have_http_status(:success) expect(assigns(:collections).map(&:title)).to eq sorted_collection_titles end + + it "sorts collections by Works, DESC by default" do + sorted_collection_titles = Collection.order("public_works_count DESC").map(&:title) + + get :index, params: { collection_search: { sort_column: "public_works_count" } } + expect(response).to have_http_status(:success) + expect(assigns(:collections).map(&:title)).to eq sorted_collection_titles + end + + it "sorts collections by Works" do + sorted_collection_titles = Collection.order("public_works_count DESC").map(&:title) + + get :index, params: { collection_search: { sort_column: "public_works_count", sort_direction: "ASC" } } + expect(response).to have_http_status(:success) + expect(assigns(:collections).map(&:title)).to eq sorted_collection_titles + end + + it "sorts collections by Bookmarks, DESC by default" do + sorted_collection_titles = Collection.order("public_bookmarked_items_count DESC").map(&:title) + + get :index, params: { collection_search: { sort_column: "public_bookmarked_items_count" } } + expect(response).to have_http_status(:success) + expect(assigns(:collections).map(&:title)).to eq sorted_collection_titles + end + + it "sorts collections by Bookmarks" do + sorted_collection_titles = Collection.order("public_bookmarked_items_count DESC").map(&:title) + + get :index, params: { collection_search: { sort_column: "public_bookmarked_items_count", sort_direction: "ASC" } } + expect(response).to have_http_status(:success) + expect(assigns(:collections).map(&:title)).to eq sorted_collection_titles + end end context "collections index for user collections" do From eb2af30810541dd6eb005e631346e2f1f6408523 Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Mon, 1 Dec 2025 15:37:52 -0500 Subject: [PATCH 03/11] AO3-7188 Clean up unused content --- app/controllers/collections_controller.rb | 2 +- app/models/search/collection_query.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 27999e27079..cc15c44ad01 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -50,7 +50,7 @@ def index @page_subtitle = ts("%{username} - Collections", username: @user.login) else @sort_and_filter = true - @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), logged_in_as_admin?) + @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), admin_logged_in=logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) end diff --git a/app/models/search/collection_query.rb b/app/models/search/collection_query.rb index d624f018235..512af83050a 100644 --- a/app/models/search/collection_query.rb +++ b/app/models/search/collection_query.rb @@ -1,8 +1,5 @@ -require 'devise/controllers/helpers' - class CollectionQuery < Query include TaggableQuery - include Devise::Controllers::Helpers # The "klass" function in the query classes is used only to determine what # type of search results to return (that is, which class the QueryResult From c12688feb6761e9d611ac5b3bec47c54dec90ab8 Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Mon, 1 Dec 2025 16:31:58 -0500 Subject: [PATCH 04/11] AO3-7188 Fix some linting and test failures --- app/controllers/collections_controller.rb | 6 +++--- app/models/search/collection_query.rb | 4 +--- app/models/search/collection_search_form.rb | 2 +- spec/models/search/collection_query_spec.rb | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index cc15c44ad01..66546e40deb 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -38,19 +38,19 @@ def index .paginate(page: params[:page]) elsif params[:collection_id] @collection = Collection.find_by!(name: params[:collection_id]) - @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in=logged_in_as_admin?) + @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = t(".subcollections_page_title", collection_title: @collection.title) elsif params[:user_id] @user = User.find_by!(login: params[:user_id]) - @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in=logged_in_as_admin?) + @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = ts("%{username} - Collections", username: @user.login) else @sort_and_filter = true - @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), admin_logged_in=logged_in_as_admin?) + @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) end diff --git a/app/models/search/collection_query.rb b/app/models/search/collection_query.rb index 512af83050a..e7aedbd63f2 100644 --- a/app/models/search/collection_query.rb +++ b/app/models/search/collection_query.rb @@ -126,10 +126,8 @@ def sort_column end def sort - if @user.present? || options[:admin_logged_in] - if sort_column.include?("public") + if (@user.present? || options[:admin_logged_in]) && sort_column.include?("public") options[:sort_column] = sort_column.sub("public", "general") - end end direction = options[:sort_direction].presence direction ||= if sort_column.include?("title") || sort_column.include?("signups_close_at") diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index 3a5c83336b1..7a02578086d 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -25,7 +25,7 @@ class CollectionSearchForm define_method(filterable) { options[filterable] } end - def initialize(opts = {}, admin_logged_in = false) + def initialize(opts = {}, admin_logged_in: false) @options = opts @options[:admin_logged_in] = admin_logged_in process_options diff --git a/spec/models/search/collection_query_spec.rb b/spec/models/search/collection_query_spec.rb index 2d7bdb0fb18..6e08d5473b1 100644 --- a/spec/models/search/collection_query_spec.rb +++ b/spec/models/search/collection_query_spec.rb @@ -19,12 +19,12 @@ expect(q.generated_query[:sort]).to eq([{ "title.keyword" => { order: "desc" } }, { "id" => { order: "desc" } }]) end - it 'sorts by bookmarked items' do + it "sorts by bookmarked items" do q = CollectionQuery.new(sort_column: "public_bookmarked_items_count", sort_direction: "desc") - expect(q.generated_query[:sort]).to eq([{ "public_bookmarkd_items_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) + expect(q.generated_query[:sort]).to eq([{ "public_bookmarked_items_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) end - it 'sorts by works' do + it "sorts by works" do q = CollectionQuery.new(sort_column: "public_works_count", sort_direction: "desc") expect(q.generated_query[:sort]).to eq([{ "public_works_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) end From 5a3c25991c2e9c781e6ffca2d73f86bfffcfdd8b Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Mon, 1 Dec 2025 16:38:19 -0500 Subject: [PATCH 05/11] AO3-7188 Fix even more linting failures --- app/models/search/collection_query.rb | 4 +--- app/models/search/collection_search_form.rb | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/search/collection_query.rb b/app/models/search/collection_query.rb index e7aedbd63f2..deb4afeb92d 100644 --- a/app/models/search/collection_query.rb +++ b/app/models/search/collection_query.rb @@ -126,9 +126,7 @@ def sort_column end def sort - if (@user.present? || options[:admin_logged_in]) && sort_column.include?("public") - options[:sort_column] = sort_column.sub("public", "general") - end + options[:sort_column] = sort_column.sub("public", "general") if (@user.present? || options[:admin_logged_in]) && sort_column.include?("public") direction = options[:sort_direction].presence direction ||= if sort_column.include?("title") || sort_column.include?("signups_close_at") "asc" diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index 7a02578086d..57132125e38 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -65,9 +65,9 @@ def sort_direction def sort_options [ ["Date Created", "created_at"], - ["Title", "title.keyword"], + %w[Title title.keyword], ["Bookmarked Items", "public_bookmarked_items_count"], - ["Works", "public_works_count"] + %w[Works public_works_count] ].freeze end From 369f54d82fb75b98047c291aaac4b7334e6d4206 Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Mon, 1 Dec 2025 17:29:58 -0500 Subject: [PATCH 06/11] AO3-7188 Revert linting change that broke test cases --- app/models/search/collection_search_form.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index 57132125e38..b06a0c0f719 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -25,7 +25,7 @@ class CollectionSearchForm define_method(filterable) { options[filterable] } end - def initialize(opts = {}, admin_logged_in: false) + def initialize(opts = {}, admin_logged_in = false) @options = opts @options[:admin_logged_in] = admin_logged_in process_options From 6ce885952b6dc75279a055417f8dd9e914c96d53 Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Tue, 2 Dec 2025 00:16:16 -0500 Subject: [PATCH 07/11] AO3-7188 Fix rspec tests to use sorting of comparison data inside ruby --- spec/controllers/collections_controller_spec.rb | 8 ++++---- spec/models/search/collection_query_spec.rb | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/spec/controllers/collections_controller_spec.rb b/spec/controllers/collections_controller_spec.rb index e5f476cf1c1..c2e9c3c0457 100644 --- a/spec/controllers/collections_controller_spec.rb +++ b/spec/controllers/collections_controller_spec.rb @@ -111,7 +111,7 @@ end it "sorts collections by Works, DESC by default" do - sorted_collection_titles = Collection.order("public_works_count DESC").map(&:title) + sorted_collection_titles = Collection.all.sort_by(&:public_works_count).reverse.map(&:title) get :index, params: { collection_search: { sort_column: "public_works_count" } } expect(response).to have_http_status(:success) @@ -119,7 +119,7 @@ end it "sorts collections by Works" do - sorted_collection_titles = Collection.order("public_works_count DESC").map(&:title) + sorted_collection_titles = Collection.all.sort_by(&:public_works_count).map(&:title) get :index, params: { collection_search: { sort_column: "public_works_count", sort_direction: "ASC" } } expect(response).to have_http_status(:success) @@ -127,7 +127,7 @@ end it "sorts collections by Bookmarks, DESC by default" do - sorted_collection_titles = Collection.order("public_bookmarked_items_count DESC").map(&:title) + sorted_collection_titles = Collection.all.sort_by(&:public_bookmarked_items_count).reverse.map(&:title) get :index, params: { collection_search: { sort_column: "public_bookmarked_items_count" } } expect(response).to have_http_status(:success) @@ -135,7 +135,7 @@ end it "sorts collections by Bookmarks" do - sorted_collection_titles = Collection.order("public_bookmarked_items_count DESC").map(&:title) + sorted_collection_titles = Collection.all.sort_by(&:public_bookmarked_items_count).map(&:title) get :index, params: { collection_search: { sort_column: "public_bookmarked_items_count", sort_direction: "ASC" } } expect(response).to have_http_status(:success) diff --git a/spec/models/search/collection_query_spec.rb b/spec/models/search/collection_query_spec.rb index 6e08d5473b1..9cac8f81f20 100644 --- a/spec/models/search/collection_query_spec.rb +++ b/spec/models/search/collection_query_spec.rb @@ -29,6 +29,16 @@ expect(q.generated_query[:sort]).to eq([{ "public_works_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) end + it "sorts by general bookmarked items when logged in" do + q = CollectionQuery.new(sort_column: "public_bookmarked_items_count", sort_direction: "desc", admin_logged_in: true) + expect(q.generated_query[:sort]).to eq([{ "general_bookmarked_items_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) + end + + it "sorts by general works when logged in" do + q = CollectionQuery.new(sort_column: "public_works_count", sort_direction: "desc", admin_logged_in: true) + expect(q.generated_query[:sort]).to eq([{ "general_works_count" => { order: "desc" } }, { "id" => { order: "desc" } }]) + end + describe "filtering", collection_search: true do let!(:gift_exchange) { create(:gift_exchange, signup_open: true, signups_open_at: Time.current - 2.days, signups_close_at: Time.current + 1.week) } let!(:gift_exchange_collection) { create(:collection, challenge: gift_exchange, challenge_type: "GiftExchange") } From 051deff0245449668cabad2a50d9b901c617d24e Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Tue, 2 Dec 2025 00:30:10 -0500 Subject: [PATCH 08/11] AO3-7188 Fix final rubocop error --- app/controllers/collections_controller.rb | 6 +++--- app/models/search/collection_search_form.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 66546e40deb..161c13704a6 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -38,19 +38,19 @@ def index .paginate(page: params[:page]) elsif params[:collection_id] @collection = Collection.find_by!(name: params[:collection_id]) - @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), logged_in_as_admin?) + @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in: logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = t(".subcollections_page_title", collection_title: @collection.title) elsif params[:user_id] @user = User.find_by!(login: params[:user_id]) - @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), logged_in_as_admin?) + @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in: logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = ts("%{username} - Collections", username: @user.login) else @sort_and_filter = true - @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), logged_in_as_admin?) + @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), admin_logged_in: logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) end diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index b06a0c0f719..57132125e38 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -25,7 +25,7 @@ class CollectionSearchForm define_method(filterable) { options[filterable] } end - def initialize(opts = {}, admin_logged_in = false) + def initialize(opts = {}, admin_logged_in: false) @options = opts @options[:admin_logged_in] = admin_logged_in process_options From ab77e0e9bc27d7f593d68bf6ba32bff6cf2153fd Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Tue, 2 Dec 2025 00:38:49 -0500 Subject: [PATCH 09/11] AO3-7188 Fix final rubocop error for good this time --- app/models/search/collection_search_form.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index 57132125e38..05a4e5388e4 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -25,9 +25,9 @@ class CollectionSearchForm define_method(filterable) { options[filterable] } end - def initialize(opts = {}, admin_logged_in: false) + def initialize(opts = {}, **kwargs) @options = opts - @options[:admin_logged_in] = admin_logged_in + @options[:admin_logged_in] = kwargs.fetch(:admin_logged_in, false) process_options @searcher = CollectionQuery.new(@options) end From 1fe7a8edf45bad01cbc3cb715ac25a3b139d7548 Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Tue, 2 Dec 2025 00:42:07 -0500 Subject: [PATCH 10/11] AO3-7188 Revert failed changes and disable rubocop for dissenting line --- app/controllers/collections_controller.rb | 6 +++--- app/models/search/collection_search_form.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 161c13704a6..66546e40deb 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -38,19 +38,19 @@ def index .paginate(page: params[:page]) elsif params[:collection_id] @collection = Collection.find_by!(name: params[:collection_id]) - @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in: logged_in_as_admin?) + @search = CollectionSearchForm.new({ parent_id: @collection.id, sort_column: "title.keyword" }.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = t(".subcollections_page_title", collection_title: @collection.title) elsif params[:user_id] @user = User.find_by!(login: params[:user_id]) - @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), admin_logged_in: logged_in_as_admin?) + @search = CollectionSearchForm.new({ maintainer_id: @user.id, sort_column: "title.keyword" }.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) @page_subtitle = ts("%{username} - Collections", username: @user.login) else @sort_and_filter = true - @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), admin_logged_in: logged_in_as_admin?) + @search = CollectionSearchForm.new(collection_filter_params.merge(page: params[:page]), logged_in_as_admin?) @collections = @search.search_results.scope(:for_search) flash_search_warnings(@collections) end diff --git a/app/models/search/collection_search_form.rb b/app/models/search/collection_search_form.rb index 05a4e5388e4..d9e453a3676 100644 --- a/app/models/search/collection_search_form.rb +++ b/app/models/search/collection_search_form.rb @@ -25,9 +25,9 @@ class CollectionSearchForm define_method(filterable) { options[filterable] } end - def initialize(opts = {}, **kwargs) + def initialize(opts = {}, admin_logged_in = false) # rubocop:disable Style/OptionalBooleanParameter @options = opts - @options[:admin_logged_in] = kwargs.fetch(:admin_logged_in, false) + @options[:admin_logged_in] = admin_logged_in process_options @searcher = CollectionQuery.new(@options) end From 16a1f7584b91617a5d67c8b2fcaae8d8bded44df Mon Sep 17 00:00:00 2001 From: kiyazz-umich Date: Tue, 2 Dec 2025 16:58:03 -0500 Subject: [PATCH 11/11] AO3-7188 Revert unneeded change to indexer --- app/models/search/collection_indexer.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/models/search/collection_indexer.rb b/app/models/search/collection_indexer.rb index 0c2d24eb465..dfe1171880e 100644 --- a/app/models/search/collection_indexer.rb +++ b/app/models/search/collection_indexer.rb @@ -47,11 +47,7 @@ def self.mapping null_value: "NULL" }, name: { type: "text", analyzer: "simple" }, - description: { type: "text", analyzer: "standard" }, - general_works_count: { type: "long" }, - public_works_count: { type: "long" }, - general_bookmarked_items_count: { type: "long" }, - public_bookmarked_items_count: { type: "long" } + description: { type: "text", analyzer: "standard" } } } end