class TrackableSessionsController < ApplicationController Mime::Type.register "application/vnd.ms-excel", :xls def index @sites = (TrackableStat.sites + ["All Sites"]).sort @time_periods = ["Past 3 Months", "Past 6 Months", "Past 12 Months"] params[:time_period] ||= 'past 3 months' if params[:site] @sessions = TrackableSession.search(params).all(:order => :created_at.desc, :limit => 25) @report = Mitamirri::StatReport.new(params) @visits = @report.visits(params) @visits_series = @visits.map{|v| v.stats} @keywords_series = Mitamirri::StatReport.keywords_by_frequency(params) @referrers_series = Mitamirri::StatReport.top_referrers(params) end end def content @sites = (TrackableStat.sites + ["All Sites"]).sort @time_periods = ["past 3 months", "past 6 months", "past 12 months"] params[:time_period] ||= 'past 3 months' params[:visit_kind] ||= 'All' if params[:site] params[:visit_kind] = 'all' if params[:visit_kind] == 'total' @report = Mitamirri::ContentReport.new(params) @pages_series = @report.pages_series(params) @entrance_pages_series = @report.entrance_pages_series(:site => params[:site], :time_period => params[:time_period]) @exit_pages_series = @report.exit_pages_series(:site => params[:site], :time_period => params[:time_period]) end end def explorer @sites = (TrackableStat.sites + ["all sites"]).sort @time_periods = ["past 3 months", "past 6 months", "past 12 months"] @kinds = TrackableAction.kinds params[:time_period] ||= 'past 3 months' params[:visit_kind] ||= 'total' params[:action_kind] ||= 'conversions' if params[:site] params[:visit_kind] = 'all' if params[:visit_kind] == 'total' @sessions = TrackableSession.search(params).all(:order => :created_at.desc, :limit => 25) @report = Mitamirri::SessionReport.new(params) @visits = @report.visits(params) @visits_series = @visits.map{|v| v.stats} @keywords_series = Mitamirri::SessionReport.keywords_by_frequency(params) @referrers_series = Mitamirri::SessionReport.top_referrers(params) end end def export @sessions = TrackableSession.search(params).all respond_to do |format| format.xls { headers['Content-Type'] = "application/vnd.ms-excel" headers['Content-Disposition'] = 'attachment; filename="sessions_export.xls"' headers['Cache-Control'] = '' } end end def leads @sites = (TrackableStat.sites + ["All Sites"]).sort @time_periods = ["Past 3 Months", "Past 6 Months", "Past 12 Months"] params[:time_period] ||= @time_periods.first if params[:site] @report = Mitamirri::LeadsReport.new(params) @leads = @report.leads(params) @leads_series = @leads.map{|l| l.stats} end end def intersite @sites = (TrackableStat.sites + ["All Sites"]).sort @time_periods = ["Past 3 Months", "Past 6 Months", "Past 12 Months"] params[:time_period] ||= @time_periods.first if params[:site] @report = Mitamirri::IntersiteTrafficReport.new(params) @total_visits = @report.total_visits(params) @total_visits_series = @total_visits.map{|v| v.stats} @destinations_series = @report.destinations(params) end end def show @trackable_session = TrackableSession.find(params[:id]) end def visitor_profile @sites = (TrackableStat.sites + ["All Sites"]).sort @time_periods = ["Past 3 Months", "Past 6 Months", "Past 12 Months"] params[:time_period] ||= @time_periods.first if params[:site] @report = Mitamirri::VisitorProfileReport.new(params) @user_agents_series = @report.user_agents_by_frequency(params) @locations_series = @report.locations_by_frequency(params) end end end