2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ZoomMeeting < ApplicationRecord
|
2021-02-22 17:27:13 +05:30
|
|
|
include Importable
|
2020-04-08 14:13:33 +05:30
|
|
|
include UsageStatistics
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
belongs_to :project
|
|
|
|
belongs_to :issue
|
|
|
|
|
|
|
|
validates :project, presence: true, unless: :importing?
|
|
|
|
validates :issue, presence: true, unless: :importing?
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
validates :url, presence: true, length: { maximum: 255 }, 'gitlab/zoom_url': true
|
2021-02-22 17:27:13 +05:30
|
|
|
validates :issue, same_project_association: true, unless: :importing?
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
enum issue_status: {
|
|
|
|
added: 1,
|
|
|
|
removed: 2
|
|
|
|
}
|
|
|
|
|
|
|
|
scope :added_to_issue, -> { where(issue_status: :added) }
|
|
|
|
scope :removed_from_issue, -> { where(issue_status: :removed) }
|
|
|
|
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
|
|
|
|
end
|