rosa-build/app/models/activity_feed.rb

25 lines
828 B
Ruby
Raw Normal View History

class ActivityFeed < ActiveRecord::Base
2014-03-13 21:36:28 +00:00
CODE = %w(git_delete_branch_notification git_new_push_notification new_comment_commit_notification)
TRACKER = %w(issue_assign_notification new_comment_notification new_issue_notification)
BUILD = %w(build_list_notification)
WIKI = %w(wiki_new_commit_notification)
2012-03-15 17:52:54 +00:00
belongs_to :user
2015-05-05 13:25:29 +01:00
belongs_to :creator, class_name: 'User'
serialize :data
2015-05-05 15:09:23 +01:00
attr_accessible :user, :kind, :data, :project_owner, :project_name, :creator_id
default_scope { order created_at: :desc }
2015-05-05 15:09:23 +01:00
scope :outdated, -> { offset(1000) }
2015-05-05 13:25:29 +01:00
scope :by_project_name, ->(name) { where(project_name: name) if name.present? }
scope :by_owner_uname, ->(owner) { where(project_owner: owner) if owner.present? }
2012-03-15 17:52:54 +00:00
2015-05-05 13:25:29 +01:00
self.per_page = 20
2012-03-15 17:52:54 +00:00
def partial
2015-05-05 13:25:29 +01:00
"home/partials/#{self.kind}"
end
end