diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-12 00:09:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-12 00:09:40 +0300 |
commit | ab82d93f5ba566b67dd1300da1cafe3ecdd13122 (patch) | |
tree | a1a9ea7b560159b49647bde0b81d3b396a077391 /app/models/concerns | |
parent | 9e40efa6a6cb39c0a4a6d7d43f7445e2d6e25172 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns')
-rw-r--r-- | app/models/concerns/users/visitable.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/concerns/users/visitable.rb b/app/models/concerns/users/visitable.rb new file mode 100644 index 00000000000..cb8e5fdc682 --- /dev/null +++ b/app/models/concerns/users/visitable.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Users + module Visitable + extend ActiveSupport::Concern + + included do + def self.visited_around?(entity_id:, user_id:, time:) + visits_around(entity_id: entity_id, user_id: user_id, time: time).any? + end + + def self.visits_around(entity_id:, user_id:, time:) + time = time.to_datetime + where(entity_id: entity_id, user_id: user_id, visited_at: (time - 15.minutes)..(time + 15.minutes)) + end + end + end +end |