Welcome to mirror list, hosted at ThFree Co, Russian Federation.

trigger.rb « ci « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d6dba3ef7c83c4f8f109a8c5e76c7512ade9a890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Ci
  class Trigger < ActiveRecord::Base
    extend Ci::Model

    acts_as_paranoid

    belongs_to :project, foreign_key: :gl_project_id
    has_many :pipelines, dependent: :destroy

    validates_presence_of :token
    validates_uniqueness_of :token

    before_validation :set_default_values

    def set_default_values
      self.token = SecureRandom.hex(15) if self.token.blank?
    end

    def last_pipeline
      pipelines.last
    end

    def last_used
      pipelines.try(:created_at)
    end

    def short_token
      token[0...10]
    end
  end
end