summaryrefslogtreecommitdiff
path: root/app/services/boards/issues
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/boards/issues')
-rw-r--r--app/services/boards/issues/list_service.rb17
-rw-r--r--app/services/boards/issues/move_service.rb6
2 files changed, 23 insertions, 0 deletions
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 0db1418b37a..0b69661bbd0 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -9,6 +9,7 @@ module Boards
fetch_issues.order_by_position_and_priority
end
+ # rubocop: disable CodeReuse/ActiveRecord
def metadata
keys = metadata_fields.keys
columns = metadata_fields.values_at(*keys).join(', ')
@@ -16,6 +17,7 @@ module Boards
Hash[keys.zip(results.flatten)]
end
+ # rubocop: enable CodeReuse/ActiveRecord
private
@@ -24,6 +26,7 @@ module Boards
end
# We memoize the query here since the finder methods we use are quite complex. This does not memoize the result of the query.
+ # rubocop: disable CodeReuse/ActiveRecord
def fetch_issues
strong_memoize(:fetch_issues) do
issues = IssuesFinder.new(current_user, filter_params).execute
@@ -31,6 +34,7 @@ module Boards
filter(issues).reorder(nil)
end
end
+ # rubocop: enable CodeReuse/ActiveRecord
def filter(issues)
issues = without_board_labels(issues) unless list&.movable? || list&.closed?
@@ -52,6 +56,7 @@ module Boards
set_parent
set_state
set_scope
+ set_non_archived
params
end
@@ -72,24 +77,36 @@ module Boards
params[:include_subgroups] = board.group_board?
end
+ def set_non_archived
+ params[:non_archived] = parent.is_a?(Group)
+ end
+
+ # rubocop: disable CodeReuse/ActiveRecord
def board_label_ids
@board_label_ids ||= board.lists.movable.pluck(:label_id)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def without_board_labels(issues)
return issues unless board_label_ids.any?
issues.where.not('EXISTS (?)', issues_label_links.limit(1))
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def issues_label_links
LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id").where(label_id: board_label_ids)
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def with_list_label(issues)
issues.where('EXISTS (?)', LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
.where("label_links.label_id = ?", list.label_id).limit(1))
end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 6fd8a23b2a1..7dd87034410 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -21,13 +21,17 @@ module Boards
moving_from_list != moving_to_list
end
+ # rubocop: disable CodeReuse/ActiveRecord
def moving_from_list
@moving_from_list ||= board.lists.find_by(id: params[:from_list_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
def moving_to_list
@moving_to_list ||= board.lists.find_by(id: params[:to_list_id])
end
+ # rubocop: enable CodeReuse/ActiveRecord
def update(issue)
::Issues::UpdateService.new(issue.project, current_user, issue_params(issue)).execute(issue)
@@ -61,6 +65,7 @@ module Boards
[moving_to_list.label_id].compact
end
+ # rubocop: disable CodeReuse/ActiveRecord
def remove_label_ids
label_ids =
if moving_to_list.movable?
@@ -73,6 +78,7 @@ module Boards
Array(label_ids).compact
end
+ # rubocop: enable CodeReuse/ActiveRecord
def move_between_ids
return unless params[:move_after_id] || params[:move_before_id]