cirandas.net

ref: master

plugins/analytics/lib/analytics_plugin.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
module AnalyticsPlugin

  TimeOnPageUpdateInterval = 2.minutes
  TimeOnPageUpdateIntervalMs = TimeOnPageUpdateInterval * 1000

  extend Noosfero::Plugin::ParentMethods

  def self.plugin_name
    I18n.t'analytics_plugin.lib.plugin.name'
  end

  def self.plugin_description
    I18n.t'analytics_plugin.lib.plugin.description'
  end

  def self.clear_non_users
    ActiveRecord::Base.transaction do
      AnalyticsPlugin::PageView.bots.delete_all
      AnalyticsPlugin::PageView.not_page_loaded.delete_all
      # delete_all does not work here
      AnalyticsPlugin::Visit.without_page_views.destroy_all
    end
  end

end

Browser::Bot.detect_empty_ua!