debian-mirror-gitlab/app/models/concerns/throttled_touch.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
373 B
Ruby
Raw Permalink Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
# 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
2021-06-08 01:23:25 +05:30
def touch(*args, **kwargs)
2018-03-17 18:26:18 +05:30
super if (Time.zone.now - updated_at) > TOUCH_INTERVAL
end
end