Commit 6cc4ac7b98b0fb2ba028644fd8dc4e2d89b65e2a
1 parent
12d08100
Exists in
spb-stable
and in
3 other branches
Drop activity observer. User EventCreateService instead
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
4 changed files
with
7 additions
and
43 deletions
Show diff stats
app/models/event.rb
... | ... | @@ -47,14 +47,6 @@ class Event < ActiveRecord::Base |
47 | 47 | scope :in_projects, ->(project_ids) { where(project_id: project_ids).recent } |
48 | 48 | |
49 | 49 | class << self |
50 | - def determine_action(record) | |
51 | - if [Issue, MergeRequest].include? record.class | |
52 | - Event::CREATED | |
53 | - elsif record.kind_of? Note | |
54 | - Event::COMMENTED | |
55 | - end | |
56 | - end | |
57 | - | |
58 | 50 | def create_ref_event(project, user, ref, action = 'add', prefix = 'refs/heads') |
59 | 51 | commit = project.repository.commit(ref.target) |
60 | 52 | ... | ... |
app/observers/activity_observer.rb
... | ... | @@ -1,35 +0,0 @@ |
1 | -class ActivityObserver < BaseObserver | |
2 | - observe :issue, :note, :milestone | |
3 | - | |
4 | - def after_create(record) | |
5 | - if record.kind_of?(Note) | |
6 | - # Skip system notes, like status changes and cross-references. | |
7 | - return true if record.system? | |
8 | - | |
9 | - # Skip wall notes to prevent spamming of dashboard | |
10 | - return true if record.noteable_type.blank? | |
11 | - end | |
12 | - | |
13 | - create_event(record, Event.determine_action(record)) if current_user | |
14 | - end | |
15 | - | |
16 | - def after_close(record, transition) | |
17 | - create_event(record, Event::CLOSED) | |
18 | - end | |
19 | - | |
20 | - def after_reopen(record, transition) | |
21 | - create_event(record, Event::REOPENED) | |
22 | - end | |
23 | - | |
24 | - protected | |
25 | - | |
26 | - def create_event(record, status) | |
27 | - Event.create( | |
28 | - project: record.project, | |
29 | - target_id: record.id, | |
30 | - target_type: record.class.name, | |
31 | - action: status, | |
32 | - author_id: current_user.id | |
33 | - ) | |
34 | - end | |
35 | -end |
app/observers/base_observer.rb
app/observers/issue_observer.rb
1 | 1 | class IssueObserver < BaseObserver |
2 | 2 | def after_create(issue) |
3 | 3 | notification.new_issue(issue, current_user) |
4 | + event_service.open_issue(issue, current_user) | |
4 | 5 | issue.create_cross_references!(issue.project, current_user) |
5 | 6 | execute_hooks(issue) |
6 | 7 | end |
7 | 8 | |
8 | 9 | def after_close(issue, transition) |
9 | 10 | notification.close_issue(issue, current_user) |
11 | + event_service.close_issue(issue, current_user) | |
10 | 12 | create_note(issue) |
11 | 13 | execute_hooks(issue) |
12 | 14 | end |
13 | 15 | |
14 | 16 | def after_reopen(issue, transition) |
17 | + event_service.reopen_issue(issue, current_user) | |
15 | 18 | create_note(issue) |
16 | 19 | execute_hooks(issue) |
17 | 20 | end | ... | ... |