Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2019-06-19 18:58:43 +0300
committerRobert Speicher <rspeicher@gmail.com>2019-06-19 18:58:43 +0300
commitea1b24cbe01d4d76fce693cbf329896e2203ae3d (patch)
treee47190ba7a7e6e40f690210cac1121882929b031 /app
parent9fa2b6578745658c36ced14a4ad1afe75c56ecc1 (diff)
parent5469d21d02d2969f7b1c629ebd5e5696c664736c (diff)
Merge branch 'pderichs-52123' into 'master'
Use NotesFinder to get Noteable See merge request gitlab-org/gitlab-ce!28205
Diffstat (limited to 'app')
-rw-r--r--app/finders/notes_finder.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb
index 817aac8b5d5..8f610d7dddb 100644
--- a/app/finders/notes_finder.rb
+++ b/app/finders/notes_finder.rb
@@ -34,8 +34,10 @@ class NotesFinder
target_type = @params[:target_type]
target_id = @params[:target_id]
+ target_iid = @params[:target_iid]
- return @target = nil unless target_type && target_id
+ return @target = nil unless target_type
+ return @target = nil unless target_id || target_iid
@target =
if target_type == "commit"
@@ -43,12 +45,22 @@ class NotesFinder
@project.commit(target_id)
end
else
- noteables_for_type(target_type).find(target_id)
+ noteables_for_type_by_id(target_type, target_id, target_iid)
end
end
private
+ def noteables_for_type_by_id(type, id, iid)
+ query = if id
+ { id: id }
+ else
+ { iid: iid }
+ end
+
+ noteables_for_type(type).find_by!(query) # rubocop: disable CodeReuse/ActiveRecord
+ end
+
def init_collection
if target
notes_on_target