Moved some behaviour to one place
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
This commit is contained in:
parent
de582ab375
commit
16eea49277
4 changed files with 9 additions and 9 deletions
|
@ -70,6 +70,12 @@ class Event < ActiveRecord::Base
|
||||||
author_id: user.id
|
author_id: user.id
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_event_cache_for(target)
|
||||||
|
Event.where(target_id: target.id, target_type: target.class.to_s).
|
||||||
|
order('id DESC').limit(100).
|
||||||
|
update_all(updated_at: Time.now)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def proper?
|
def proper?
|
||||||
|
|
|
@ -67,8 +67,6 @@ class Issue < ActiveRecord::Base
|
||||||
# Thus it will automatically generate a new fragment
|
# Thus it will automatically generate a new fragment
|
||||||
# when the event is updated because the key changes.
|
# when the event is updated because the key changes.
|
||||||
def reset_events_cache
|
def reset_events_cache
|
||||||
Event.where(target_id: self.id, target_type: 'Issue').
|
Event.reset_event_cache_for(self)
|
||||||
order('id DESC').limit(100).
|
|
||||||
update_all(updated_at: Time.now)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -287,9 +287,7 @@ class MergeRequest < ActiveRecord::Base
|
||||||
# Thus it will automatically generate a new fragment
|
# Thus it will automatically generate a new fragment
|
||||||
# when the event is updated because the key changes.
|
# when the event is updated because the key changes.
|
||||||
def reset_events_cache
|
def reset_events_cache
|
||||||
Event.where(target_id: self.id, target_type: 'MergeRequest').
|
Event.reset_event_cache_for(self)
|
||||||
order('id DESC').limit(100).
|
|
||||||
update_all(updated_at: Time.now)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge_commit_message
|
def merge_commit_message
|
||||||
|
|
|
@ -327,9 +327,7 @@ class Note < ActiveRecord::Base
|
||||||
# Thus it will automatically generate a new fragment
|
# Thus it will automatically generate a new fragment
|
||||||
# when the event is updated because the key changes.
|
# when the event is updated because the key changes.
|
||||||
def reset_events_cache
|
def reset_events_cache
|
||||||
Event.where(target_id: self.id, target_type: 'Note').
|
Event.reset_event_cache_for(self)
|
||||||
order('id DESC').limit(100).
|
|
||||||
update_all(updated_at: Time.now)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_references
|
def set_references
|
||||||
|
|
Loading…
Reference in a new issue