Class: SirTracksAlot::Reports::ActorActivityReport
- Inherits:
-
SirTracksAlotReport
- Object
- Ruport::Controller
- Report
- SirTracksAlotReport
- SirTracksAlot::Reports::ActorActivityReport
- Defined in:
- lib/sir_tracks_alot/reports/actor_activity_report.rb
Defined Under Namespace
Modules: Helpers Classes: HTML
Constant Summary collapse
- COLUMN_NAMES =
['target', 'page views', 'visits']
Instance Attribute Summary
Attributes inherited from SirTracksAlotReport
Attributes inherited from Report
Instance Method Summary collapse
Methods inherited from Report
Instance Method Details
#setup ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sir_tracks_alot/reports/actor_activity_report.rb', line 9 def setup super counts = {} .column_names ||= COLUMN_NAMES activities = Activity.find(:owner => .owner, :actor => .actor) activities.each do |activity| counts[activity.target] ||= [0,0] counts[activity.target][0] += activity.views counts[activity.target][1] += activity.visits(.session_duration) end table = Table(.column_names) do |t| counts.each do |target, count| t << [target, count[0], count[1]] end end table.sort_rows_by!('page views', :order => :descending) self.data = table end |