diff options
Diffstat (limited to 'app/models/metrics')
-rw-r--r-- | app/models/metrics/users_starred_dashboard.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/models/metrics/users_starred_dashboard.rb b/app/models/metrics/users_starred_dashboard.rb new file mode 100644 index 00000000000..07748eb1431 --- /dev/null +++ b/app/models/metrics/users_starred_dashboard.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Metrics + class UsersStarredDashboard < ApplicationRecord + self.table_name = 'metrics_users_starred_dashboards' + + belongs_to :user, inverse_of: :metrics_users_starred_dashboards + belongs_to :project, inverse_of: :metrics_users_starred_dashboards + + validates :user_id, presence: true + validates :project_id, presence: true + validates :dashboard_path, presence: true, length: { maximum: 255 } + validates :dashboard_path, uniqueness: { scope: %i[user_id project_id] } + + scope :for_project, ->(project) { where(project: project) } + scope :for_project_dashboard, ->(project, path) { for_project(project).where(dashboard_path: path) } + end +end |