-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.rb
52 lines (44 loc) · 1.08 KB
/
check.rb
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true
# == Schema Information
#
# Table name: repository_checks
#
# id :integer not null, primary key
# aasm_state :string
# issues :json
# issues_count :integer default(0)
# passed :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
# commit_id :string
# repository_id :integer not null
#
# Indexes
#
# index_repository_checks_on_repository_id (repository_id)
#
# Foreign Keys
#
# repository_id (repository_id => repositories.id)
#
class Repository::Check < ApplicationRecord
include AASM
belongs_to :repository
aasm do
state :created, initial: true
state :in_process, :failed, :finished
event :start do
transitions from: :created, to: :in_process
end
event :fail do
transitions from: :in_process, to: :failed
end
event :finish do
transitions from: :in_process, to: :finished
end
end
include Repository::CheckRepository
def with_issues?
issues_count.positive?
end
end