app/services/hyrax/workflow/permission_query.rb in hyrax-3.6.0 vs app/services/hyrax/workflow/permission_query.rb in hyrax-4.0.0.beta1
- old
+ new
@@ -192,11 +192,11 @@
# @param [User] user
#
# @return [ActiveRecord::Relation<Sipity::Entity>]
#
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
- def scope_entities_for_the_user(user:, page: 1, per_page: nil, workflow_state_filter: nil)
+ def scope_entities_for_the_user(user:)
entities = Sipity::Entity.arel_table
workflow_state_actions = Sipity::WorkflowStateAction.arel_table
workflow_states = Sipity::WorkflowState.arel_table
workflow_state_action_permissions = Sipity::WorkflowStateActionPermission.arel_table
@@ -225,37 +225,16 @@
workflow_specific_joins = join_builder.call(workflow_responsibilities)
entity_specific_where = where_builder.call(entity_responsibilities).and(
entities[:id].eq(entity_responsibilities[:entity_id])
)
- entity_specific_where = filter_by_workflow_state(entity_specific_where, workflow_states, workflow_state_filter) if workflow_state_filter
workflow_specific_where = where_builder.call(workflow_responsibilities)
- workflow_specific_where = filter_by_workflow_state(workflow_specific_where, workflow_states, workflow_state_filter) if workflow_state_filter
- result = Sipity::Entity.where(
+ Sipity::Entity.where(
entities[:id].in(entity_specific_joins.where(entity_specific_where))
.or(entities[:id].in(workflow_specific_joins.where(workflow_specific_where)))
)
- # Apply paging if provided
- if per_page.nil?
- result
- else
- result.page(page).per(per_page)
- end
end
-
- # @api private
- #
- # Append a filter by workflow state name to the provided where builder.
- # If the filter begins with a !, it will filter to states not equal to the filter.
- def filter_by_workflow_state(where_builder, workflow_states, filter)
- if filter.start_with?('!')
- where_builder.and(workflow_states[:name].not_eq(filter[1..-1]))
- else
- where_builder.and(workflow_states[:name].eq(filter))
- end
- end
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
# @api public
#
# An ActiveRecord::Relation scope that meets the following criteria: