diff options
author | Stan Hu <stanhu@gmail.com> | 2019-07-27 01:29:07 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-07-27 01:29:07 +0300 |
commit | 7dccb44448aed3227072154f2385383c54f2d4f6 (patch) | |
tree | 8018495ca105fed75101f8546182bbe0521a914e /app/controllers | |
parent | e59ba979446b6c8539f3569b693fe24836fe75ac (diff) | |
parent | 355a2df560dea2719a027ada718a923ab7876ffe (diff) |
Merge branch '52123-issuable-actions-notesfinder-pderichs' into 'master'
Use NotesFinder to fetch notes in module IssuableActions
Closes #52123
See merge request gitlab-org/gitlab-ce!29733
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/issuable_actions.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index 6fa2f75be33..94d1e8248fc 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -98,13 +98,12 @@ module IssuableActions render json: { notice: "#{quantity} #{resource_name.pluralize(quantity)} updated" } end - # rubocop: disable CodeReuse/ActiveRecord + # rubocop:disable CodeReuse/ActiveRecord def discussions - notes = issuable.discussion_notes - .inc_relations_for_view - .with_notes_filter(notes_filter) - .includes(:noteable) - .fresh + notes = NotesFinder.new(project, current_user, finder_params_for_issuable).execute + .inc_relations_for_view + .includes(:noteable) + .fresh if notes_filter != UserPreference::NOTES_FILTERS[:only_comments] notes = ResourceEvents::MergeIntoNotesService.new(issuable, current_user).execute(notes) @@ -117,7 +116,7 @@ module IssuableActions render json: discussion_serializer.represent(discussions, context: self) end - # rubocop: enable CodeReuse/ActiveRecord + # rubocop:enable CodeReuse/ActiveRecord private @@ -222,4 +221,13 @@ module IssuableActions def parent @project || @group # rubocop:disable Gitlab/ModuleWithInstanceVariables end + + # rubocop:disable Gitlab/ModuleWithInstanceVariables + def finder_params_for_issuable + { + target: @issuable, + notes_filter: notes_filter + } + end + # rubocop:enable Gitlab/ModuleWithInstanceVariables end |