From 0ad6f6cdadb97b8f67aa1079bd77401e2614e77c Mon Sep 17 00:00:00 2001 From: Ben Pennell Date: Fri, 31 Mar 2023 18:31:56 -0400 Subject: [PATCH] Rubocop --- .../hyrax/admin/workflows_controller.rb | 38 +++++++++++-------- .../hyrax/workflow/actionable_objects.rb | 4 +- .../hyrax/workflow/permission_query.rb | 4 +- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/controllers/hyrax/admin/workflows_controller.rb b/app/controllers/hyrax/admin/workflows_controller.rb index f49eb9afc5..ac560728a0 100644 --- a/app/controllers/hyrax/admin/workflows_controller.rb +++ b/app/controllers/hyrax/admin/workflows_controller.rb @@ -15,19 +15,8 @@ def index add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path add_breadcrumb t(:'hyrax.admin.sidebar.tasks'), '#' add_breadcrumb t(:'hyrax.admin.sidebar.workflow_review'), request.path - page = params.fetch('page', 1) - per_page = params.fetch('per_page', 10) - actionable_objects.page = page - actionable_objects.per_page = per_page - actionable_objects.query = params['q'] - under_review = viewing_under_review?(params['state']) - if under_review - state = 'under-review' - actionable_objects.workflow_state_filter = '!' + self.deposited_workflow_state_name - else - actionable_objects.workflow_state_filter = self.deposited_workflow_state_name - end - @response = WorkflowResponse.new(actionable_objects.to_a, actionable_objects.total_count, page, per_page, under_review) + assign_action_objects_params + @response = WorkflowResponse.new(actionable_objects.to_a, actionable_objects.total_count, current_page, per_page, under_review?) end private @@ -45,8 +34,27 @@ def actionable_objects Hyrax::Workflow::ActionableObjects.new(user: current_user) end - def viewing_under_review?(state) - state != 'published' + def current_page + @page ||= params.fetch('page', 1).to_i + end + + def per_page + @per_page ||= params.fetch('per_page', 10).to_i + end + + def query + @query ||= params['q'] + end + + def assign_action_objects_params + actionable_objects.page = current_page + actionable_objects.per_page = per_page + actionable_objects.query = query + actionable_objects.workflow_state_filter = (under_review? ? '!' : '') + deposited_workflow_state_name + end + + def under_review? + @under_review = params['state'] != 'published' end class WorkflowResponse diff --git a/app/services/hyrax/workflow/actionable_objects.rb b/app/services/hyrax/workflow/actionable_objects.rb index 0233f96c3b..bf1eb0b91d 100644 --- a/app/services/hyrax/workflow/actionable_objects.rb +++ b/app/services/hyrax/workflow/actionable_objects.rb @@ -56,9 +56,7 @@ def each # starting_query = query ? [{'title_tesim' : query}] : [] query_service = Hyrax::SolrQueryService.new - if query - query_service.with_field_pairs(field_pairs: {'title_tesim' => query}) - end + query_service.with_field_pairs(field_pairs: { 'title_tesim' => query }) if query docs = query_service.with_ids(ids: ids_and_states.map(&:first)) .solr_documents diff --git a/app/services/hyrax/workflow/permission_query.rb b/app/services/hyrax/workflow/permission_query.rb index 7d3966a883..e538c341df 100644 --- a/app/services/hyrax/workflow/permission_query.rb +++ b/app/services/hyrax/workflow/permission_query.rb @@ -228,9 +228,7 @@ def scope_entities_for_the_user(user:, page: 1, per_page: nil, workflow_state_fi entities[:id].eq(entity_responsibilities[:entity_id]) ) workflow_specific_where = where_builder.call(workflow_responsibilities) - if workflow_state_filter - workflow_specific_where = filter_by_workflow_state(workflow_specific_where, workflow_states, workflow_state_filter) - end + workflow_specific_where = filter_by_workflow_state(workflow_specific_where, workflow_states, workflow_state_filter) if workflow_state_filter result = Sipity::Entity.where( entities[:id].in(entity_specific_joins.where(entity_specific_where))