2020-04-29 20:09:37 -04:00
|
|
|
# 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] }
|
2020-05-11 14:09:55 -04:00
|
|
|
|
|
|
|
scope :for_project, ->(project) { where(project: project) }
|
|
|
|
scope :for_project_dashboard, ->(project, path) { for_project(project).where(dashboard_path: path) }
|
2020-04-29 20:09:37 -04:00
|
|
|
end
|
|
|
|
end
|