debian-mirror-gitlab/app/models/concerns/throttled_touch.rb
2018-03-17 18:26:18 +05:30

11 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