summaryrefslogtreecommitdiff
path: root/app/models/board_project_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_project_recent_visit.rb
parentc33a9adb709ffb40f816e66eb0c98cc750d6cd43 (diff)
downloadgitlab-ce-e3042fc5ced749e693ccef81b3f5838c55d5480c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/board_project_recent_visit.rb')
-rw-r--r--app/models/board_project_recent_visit.rb20
1 files changed, 6 insertions, 14 deletions
diff --git a/app/models/board_project_recent_visit.rb b/app/models/board_project_recent_visit.rb
index 509c8f97b83..723afd6feab 100644
--- a/app/models/board_project_recent_visit.rb
+++ b/app/models/board_project_recent_visit.rb
@@ -2,27 +2,19 @@
# Tracks which boards in a specific project a user has visited
class BoardProjectRecentVisit < ApplicationRecord
+ include BoardRecentVisit
+
belongs_to :user
belongs_to :project
belongs_to :board
- validates :user, presence: true
+ validates :user, presence: true
validates :project, presence: true
validates :board, presence: true
- scope :by_user_project, -> (user, project) { where(user: user, project: project) }
-
- def self.visited!(user, board)
- visit = find_or_create_by(user: user, project: board.project, board: board)
- visit.touch if visit.updated_at < Time.current
- rescue ActiveRecord::RecordNotUnique
- retry
- end
-
- def self.latest(user, project, count: nil)
- visits = by_user_project(user, project).order(updated_at: :desc)
- visits = visits.preload(:board) if count && count > 1
+ scope :by_user_parent, -> (user, project) { where(user: user, project: project) }
- visits.first(count)
+ def self.board_parent_relation
+ :project
end
end