event.rb 732 字节
Newer Older
D
Dmitriy Zaporozhets 已提交
1
class Event < ActiveRecord::Base
2 3 4 5 6 7 8
  Created   = 1
  Updated   = 2
  Closed    = 3
  Reopened  = 4
  Pushed    = 5
  Commented = 6

D
Dmitriy Zaporozhets 已提交
9
  belongs_to :project
10 11
  belongs_to :target, :polymorphic => true

D
Dmitriy Zaporozhets 已提交
12
  serialize :data
13 14 15 16 17 18 19 20

  def self.determine_action(record)
    if [Issue, MergeRequest].include? record.class
      Event::Created
    elsif record.kind_of? Note
      Event::Commented
    end
  end
D
Dmitriy Zaporozhets 已提交
21 22 23 24 25
end
# == Schema Information
#
# Table name: events
#
26 27 28 29 30 31 32 33 34
#  id          :integer         not null, primary key
#  target_type :string(255)
#  target_id   :integer
#  title       :string(255)
#  data        :text
#  project_id  :integer
#  created_at  :datetime        not null
#  updated_at  :datetime        not null
#  action      :integer
D
Dmitriy Zaporozhets 已提交
35
#
36