From f1b2d3306fee5e6b5b5c724df4017eae34aaf85b Mon Sep 17 00:00:00 2001 From: Audrey Hamelers Date: Tue, 4 Jun 2024 18:03:34 +0200 Subject: [PATCH 1/3] page size fix (weird!) --- .../stash_engine/publication_updater_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/stash_engine/publication_updater_controller.rb b/app/controllers/stash_engine/publication_updater_controller.rb index f457de2c65..aec5f3612b 100644 --- a/app/controllers/stash_engine/publication_updater_controller.rb +++ b/app/controllers/stash_engine/publication_updater_controller.rb @@ -86,7 +86,11 @@ def destroy def setup_paging @page = params[:page] || '1' - @page_size = (params[:page_size].blank? || params[:page_size] != '1000000' ? '10' : '1000000') + @page_size = if params[:page_size].blank? || params[:page_size].to_i == 0 + 10 + else + params[:page_size].to_i + end end def setup_filter From a098c4ed01874e02f170ddbd8758e984a9788bf5 Mon Sep 17 00:00:00 2001 From: Audrey Hamelers Date: Tue, 4 Jun 2024 18:03:49 +0200 Subject: [PATCH 2/3] search filters fix --- .../stash_engine/publication_updater_controller.rb | 4 ++-- app/views/stash_engine/publication_updater/index.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/stash_engine/publication_updater_controller.rb b/app/controllers/stash_engine/publication_updater_controller.rb index aec5f3612b..210cfdced6 100644 --- a/app/controllers/stash_engine/publication_updater_controller.rb +++ b/app/controllers/stash_engine/publication_updater_controller.rb @@ -114,13 +114,13 @@ def add_param_filters(proposed_changes) proposed_changes = proposed_changes.where((['search_table.big_text LIKE ?'] * keys.size).join(' AND '), *keys.map { |key| "%#{key}%" }) end - if params[:status] + if params[:status].present? proposed_changes = proposed_changes.joins( 'JOIN stash_engine_curation_activities sa ON sa.id = stash_engine_resources.last_curation_activity_id' ).where('sa.status' => params[:status]) end - if params[:match_type] + if params[:match_type].present? proposed_changes = proposed_changes.where( "stash_engine_proposed_changes.publication_issn is #{params[:match_type] == 'preprints' ? 'null' : 'not null'}" ) diff --git a/app/views/stash_engine/publication_updater/index.html.erb b/app/views/stash_engine/publication_updater/index.html.erb index c0bbd7dc97..ca8b3fc7b0 100644 --- a/app/views/stash_engine/publication_updater/index.html.erb +++ b/app/views/stash_engine/publication_updater/index.html.erb @@ -33,7 +33,7 @@ <%= select_tag :status, options_from_collection_for_select(@statuses, "value", "label", params[:status]), class: 'c-input__text' %> - <%= submit_tag('Search', class: 'o-button__submit' ) %> + <%= submit_tag('Search', class: 'o-button__submit', name: nil ) %> <%= button_tag "Reset", type: :reset, id: 'reset_button', class: "o-button__remove" %> <% end %> From 6c310ca0297421bd21b2556ea5c5ad477b94f551 Mon Sep 17 00:00:00 2001 From: Audrey Hamelers Date: Tue, 4 Jun 2024 18:22:44 +0200 Subject: [PATCH 3/3] pubupdater page count fix attempt --- .../stash_engine/publication_updater_controller.rb | 5 +---- app/models/stash_engine/proposed_change.rb | 3 +++ app/views/stash_engine/publication_updater/index.html.erb | 6 +----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/controllers/stash_engine/publication_updater_controller.rb b/app/controllers/stash_engine/publication_updater_controller.rb index 210cfdced6..a46d1f2658 100644 --- a/app/controllers/stash_engine/publication_updater_controller.rb +++ b/app/controllers/stash_engine/publication_updater_controller.rb @@ -26,8 +26,7 @@ class PublicationUpdaterController < ApplicationController # the admin datasets main page showing users and stats, but slightly different in scope for curators vs tenant admins def index - proposed_changes = authorize StashEngine::ProposedChange # .includes(identifier: :latest_resource) - .joins(identifier: :latest_resource).where(approved: false, rejected: false) + proposed_changes = authorize StashEngine::ProposedChange.unprocessed.joins(:latest_resource) .where("stash_engine_identifiers.pub_state != 'withdrawn'") .select('stash_engine_proposed_changes.*') @@ -52,8 +51,6 @@ def index @proposed_changes = proposed_changes.order(ord).page(@page).per(@page_size) return unless @proposed_changes.present? - @resources = StashEngine::Resource.latest_per_dataset.where(identifier_id: @proposed_changes&.map(&:identifier_id)) - respond_to do |format| format.html format.csv do diff --git a/app/models/stash_engine/proposed_change.rb b/app/models/stash_engine/proposed_change.rb index 806063ba22..30929c5a89 100644 --- a/app/models/stash_engine/proposed_change.rb +++ b/app/models/stash_engine/proposed_change.rb @@ -36,8 +36,11 @@ module StashEngine class ProposedChange < ApplicationRecord self.table_name = 'stash_engine_proposed_changes' belongs_to :identifier, class_name: 'StashEngine::Identifier', foreign_key: 'identifier_id' + has_one :latest_resource, class_name: 'StashEngine::Resource', through: :identifier belongs_to :user, class_name: 'StashEngine::User', foreign_key: 'user_id', optional: true + scope :unprocessed, -> { where(approved: false, rejected: false) } + CROSSREF_PUBLISHED_MESSAGE = 'reported that the related journal has been published'.freeze CROSSREF_UPDATE_MESSAGE = 'provided additional metadata'.freeze diff --git a/app/views/stash_engine/publication_updater/index.html.erb b/app/views/stash_engine/publication_updater/index.html.erb index ca8b3fc7b0..1202b81517 100644 --- a/app/views/stash_engine/publication_updater/index.html.erb +++ b/app/views/stash_engine/publication_updater/index.html.erb @@ -64,11 +64,7 @@ <% @proposed_changes.each do |proposed_change| %> - <% resource = @resources.select{ |r| r.identifier_id == proposed_change.identifier_id }.first %> - <% if resource.present? %> - <%= render partial: 'proposed_change_line', - locals: { proposed_change: proposed_change, resource: resource } %> - <% end %> + <%= render partial: 'proposed_change_line',locals: { proposed_change: proposed_change, resource: proposed_change.latest_resource } %> <% end %>