ref: master
plugins/analytics/lib/ext/profile.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 |
require_dependency 'profile' class Profile has_many :users_visits, -> { latest.with_users_page_views }, foreign_key: :profile_id, class_name: 'AnalyticsPlugin::Visit' has_many :visits, -> { latest.eager_load :page_views }, foreign_key: :profile_id, class_name: 'AnalyticsPlugin::Visit' has_many :page_views, foreign_key: :profile_id, class_name: 'AnalyticsPlugin::PageView' has_many :user_visits, -> { latest.eager_load :page_views }, foreign_key: :user_id, class_name: 'AnalyticsPlugin::PageView' has_many :user_page_views, foreign_key: :user_id, class_name: 'AnalyticsPlugin::PageView' def analytics_settings attrs = {} @analytics_settings ||= Noosfero::Plugin::Settings.new self, ::AnalyticsPlugin, attrs attrs.each{ |a, v| @analytics_settings.send "#{a}=", v } @analytics_settings end alias_method :analytics_settings=, :analytics_settings def analytics_enabled? self.analytics_settings.enabled end def analytics_anonymous? self.analytics_settings.anonymous end end |