simple refactoring

This commit is contained in:
Andrey Kumanyaev 2012-10-09 04:10:04 +04:00
parent a635b9da97
commit df7c52489a
21 changed files with 276 additions and 264 deletions

View file

@ -27,19 +27,22 @@ class Event < ActiveRecord::Base
# For Hash only
serialize :data
# Scopes
scope :recent, order("created_at DESC")
scope :code_push, where(action: Pushed)
def self.determine_action(record)
if [Issue, MergeRequest].include? record.class
Event::Created
elsif record.kind_of? Note
Event::Commented
class << self
def determine_action(record)
if [Issue, MergeRequest].include? record.class
Event::Created
elsif record.kind_of? Note
Event::Commented
end
end
end
def self.recent_for_user user
where(project_id: user.projects.map(&:id)).recent
def recent_for_user user
where(project_id: user.projects.map(&:id)).recent
end
end
# Next events currently enabled for system