Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pubupdater page counts #1679

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions app/controllers/stash_engine/publication_updater_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.*')

Expand All @@ -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
Expand Down Expand Up @@ -86,7 +83,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
Expand All @@ -110,13 +111,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'}"
)
Expand Down
3 changes: 3 additions & 0 deletions app/models/stash_engine/proposed_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions app/views/stash_engine/publication_updater/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<label for="status">Curation status:</label>
<%= select_tag :status, options_from_collection_for_select(@statuses, "value", "label", params[:status]), class: 'c-input__text' %>
</div>
<%= 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" %>
</div>
<% end %>
Expand Down Expand Up @@ -64,11 +64,7 @@
</thead>
<tbody>
<% @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 %>
</tbody>
</table>
Expand Down
Loading