diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-16 19:03:42 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-01-16 19:03:42 +0200 |
commit | 1d2bdb4d5880bb1ad39b62c81ff2971aa0cb3798 (patch) | |
tree | 8ac3215b2c25cb57b5f2198fd4d85c7bad968c2b /app/services/notes | |
parent | dba982403b7b894d2096ea61b89a247060eefe57 (diff) | |
download | gitlab-ce-1d2bdb4d5880bb1ad39b62c81ff2971aa0cb3798.tar.gz |
Move all Context classes into Services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/services/notes')
-rw-r--r-- | app/services/notes/create_service.rb | 10 | ||||
-rw-r--r-- | app/services/notes/load_service.rb | 20 |
2 files changed, 30 insertions, 0 deletions
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb new file mode 100644 index 00000000000..fb87e175933 --- /dev/null +++ b/app/services/notes/create_service.rb @@ -0,0 +1,10 @@ +module Notes + class CreateService < BaseService + def execute + note = project.notes.new(params[:note]) + note.author = current_user + note.save + note + end + end +end diff --git a/app/services/notes/load_service.rb b/app/services/notes/load_service.rb new file mode 100644 index 00000000000..f7ad7d60a3a --- /dev/null +++ b/app/services/notes/load_service.rb @@ -0,0 +1,20 @@ +module Notes + class LoadService < BaseService + def execute + target_type = params[:target_type] + target_id = params[:target_id] + + + @notes = case target_type + when "commit" + project.notes.for_commit_id(target_id).not_inline.fresh + when "issue" + project.issues.find(target_id).notes.inc_author.fresh + when "merge_request" + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh + when "snippet" + project.snippets.find(target_id).notes.fresh + end + end + end +end |