856447ccd3
This throttles the number of UPDATE queries that can be triggered by calling "touch" on a Note, Issue, or MergeRequest. For Note objects we also take care of updating the associated "noteable" relation in a smarter way than Rails does by default.
10 lines
332 B
Ruby
10 lines
332 B
Ruby
# ThrottledTouch can be used to throttle the number of updates triggered by
|
|
# calling "touch" on an ActiveRecord model.
|
|
module ThrottledTouch
|
|
# The amount of time to wait before "touch" can update a record again.
|
|
TOUCH_INTERVAL = 1.minute
|
|
|
|
def touch(*args)
|
|
super if (Time.zone.now - updated_at) > TOUCH_INTERVAL
|
|
end
|
|
end
|