2019-10-21 17:06:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ZoomMeeting < ApplicationRecord
|
2020-12-16 10:10:18 -05:00
|
|
|
include Importable
|
2020-03-16 20:09:12 -04:00
|
|
|
include UsageStatistics
|
|
|
|
|
2020-12-16 10:10:18 -05:00
|
|
|
belongs_to :project
|
|
|
|
belongs_to :issue
|
|
|
|
|
|
|
|
validates :project, presence: true, unless: :importing?
|
|
|
|
validates :issue, presence: true, unless: :importing?
|
2019-10-21 17:06:14 -04:00
|
|
|
|
2021-09-06 23:11:39 -04:00
|
|
|
validates :url, presence: true, length: { maximum: 255 }, 'gitlab/zoom_url': true
|
2020-12-16 10:10:18 -05:00
|
|
|
validates :issue, same_project_association: true, unless: :importing?
|
2019-10-21 17:06:14 -04:00
|
|
|
|
|
|
|
enum issue_status: {
|
|
|
|
added: 1,
|
|
|
|
removed: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
scope :added_to_issue, -> { where(issue_status: :added) }
|
|
|
|
scope :removed_from_issue, -> { where(issue_status: :removed) }
|
2019-10-28 14:06:15 -04:00
|
|
|
scope :canonical, -> (issue) { where(issue: issue).added_to_issue }
|
|
|
|
|
|
|
|
def self.canonical_meeting(issue)
|
|
|
|
canonical(issue)&.take
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.canonical_meeting_url(issue)
|
|
|
|
canonical_meeting(issue)&.url
|
|
|
|
end
|
2019-10-21 17:06:14 -04:00
|
|
|
end
|