summaryrefslogtreecommitdiff
path: root/app/models/board_group_recent_visit.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-11 15:10:20 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-11 15:10:20 +0000
commite3042fc5ced749e693ccef81b3f5838c55d5480c (patch)
treee004dca26da0ec413d5c9ebf174962a008fde0bb /app/models/board_group_recent_visit.rb
parentc33a9adb709ffb40f816e66eb0c98cc750d6cd43 (diff)
downloadgitlab-ce-e3042fc5ced749e693ccef81b3f5838c55d5480c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/board_group_recent_visit.rb')
-rw-r--r--app/models/board_group_recent_visit.rb20
1 files changed, 6 insertions, 14 deletions
diff --git a/app/models/board_group_recent_visit.rb b/app/models/board_group_recent_visit.rb
index 979f0e1ab92..dc273e256a8 100644
--- a/app/models/board_group_recent_visit.rb
+++ b/app/models/board_group_recent_visit.rb
@@ -2,27 +2,19 @@
# Tracks which boards in a specific group a user has visited
class BoardGroupRecentVisit < ApplicationRecord
+ include BoardRecentVisit
+
belongs_to :user
belongs_to :group
belongs_to :board
- validates :user, presence: true
+ validates :user, presence: true
validates :group, presence: true
validates :board, presence: true
- scope :by_user_group, -> (user, group) { where(user: user, group: group) }
-
- def self.visited!(user, board)
- visit = find_or_create_by(user: user, group: board.group, board: board)
- visit.touch if visit.updated_at < Time.current
- rescue ActiveRecord::RecordNotUnique
- retry
- end
-
- def self.latest(user, group, count: nil)
- visits = by_user_group(user, group).order(updated_at: :desc)
- visits = visits.preload(:board) if count && count > 1
+ scope :by_user_parent, -> (user, group) { where(user: user, group: group) }
- visits.first(count)
+ def self.board_parent_relation
+ :group
end
end