Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
f9218898
Commit
f9218898
authored
Jan 27, 2016
by
Josh Frye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] Background process note logic for #3948
parent
88e16c3d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
18 deletions
+45
-18
app/controllers/projects/notes_controller.rb
app/controllers/projects/notes_controller.rb
+1
-1
app/services/notes/create_service.rb
app/services/notes/create_service.rb
+2
-17
app/services/notes/post_process_service.rb
app/services/notes/post_process_service.rb
+30
-0
app/workers/new_note_worker.rb
app/workers/new_note_worker.rb
+12
-0
No files found.
app/controllers/projects/notes_controller.rb
View file @
f9218898
app/services/notes/create_service.rb
View file @
f9218898
...
...
@@ -6,27 +6,12 @@ module Notes
note
.
system
=
false
if
note
.
save
notification_service
.
new_note
(
note
)
# Skip system notes, like status changes and cross-references and awards
unless
note
.
system
||
note
.
is_award
event_service
.
leave_note
(
note
,
note
.
author
)
note
.
create_cross_references!
execute_hooks
(
note
)
end
# Finish the harder work in the background
NewNoteWorker
.
perform_in
(
2
.
seconds
,
note
.
id
,
params
)
end
note
end
def
hook_data
(
note
)
Gitlab
::
NoteDataBuilder
.
build
(
note
,
current_user
)
end
def
execute_hooks
(
note
)
note_data
=
hook_data
(
note
)
note
.
project
.
execute_hooks
(
note_data
,
:note_hooks
)
note
.
project
.
execute_services
(
note_data
,
:note_hooks
)
end
end
end
app/services/notes/post_process_service.rb
0 → 100644
View file @
f9218898
module
Notes
class
PostProcessService
attr_accessor
:note
def
initialize
(
note
)
@note
=
note
end
def
execute
# Skip system notes, like status changes and cross-references and awards
unless
@note
.
system
||
@note
.
is_award
EventCreateService
.
new
.
leave_note
(
@note
,
@note
.
author
)
@note
.
create_cross_references!
execute_note_hooks
end
end
def
hook_data
Gitlab
::
NoteDataBuilder
.
build
(
@note
,
@note
.
author
)
end
def
execute_note_hooks
note_data
=
hook_data
@note
.
project
.
execute_hooks
(
note_data
,
:note_hooks
)
@note
.
project
.
execute_services
(
note_data
,
:note_hooks
)
end
end
end
app/workers/new_note_worker.rb
0 → 100644
View file @
f9218898
class
NewNoteWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
note_id
,
note_params
)
note
=
Note
.
find
(
note_id
)
NotificationService
.
new
.
new_note
(
note
)
Notes
::
PostProcessService
.
new
(
note
).
execute
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment