cirandas.net

ref: master

plugins/spaminator/lib/spaminator_plugin/report.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
class SpaminatorPlugin::Report < ApplicationRecord

  serialize :failed, Hash

  belongs_to :environment

  validates_presence_of :environment

  attr_accessible :environment

  scope :from_environment, -> environment { where :environment_id => environment }

  after_initialize do |report|
    report.failed = {:people => [], :comments => []} if report.failed.blank?
  end

  def spams
    spams_by_no_network + spams_by_content
  end

  def spammers
    spammers_by_no_network + spammers_by_comments
  end

  def formated_date
    created_at.strftime("%Y-%m-%d")
  end

  def details
    # TODO Implement some decent visualization
    inspect
  end

end