Skip to content

Commit

Permalink
Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
bbpennel committed Mar 31, 2023
1 parent 4c898c4 commit 0ad6f6c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
38 changes: 23 additions & 15 deletions app/controllers/hyrax/admin/workflows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions app/services/hyrax/workflow/actionable_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions app/services/hyrax/workflow/permission_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 0ad6f6c

Please sign in to comment.