Welcome to mirror list, hosted at ThFree Co, Russian Federation.

throttled_touch.rb « concerns « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 797c46f6cc545e6df5734b3d20fb8d0fc13a0ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
# frozen_string_literal: true

# 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