Permalink
Browse files

First implementation of widgets using jquery-ui

  • Loading branch information...
1 parent d6893dc commit 670e7d724aa70f9f264125a1c179f6e0b451c688 @rosario committed May 4, 2009
Showing 475 changed files with 61,986 additions and 235 deletions.
@@ -12,7 +12,7 @@ def index
redirect_to :controller =>'dashboard', :action=> 'setup'
else
session[:project_id] = pid
- redirect_to project_overview_url(:id =>pid)
+ redirect_to project_index_url
end
end
@@ -26,12 +26,11 @@ def create
u = User.find(session[:user_id])
project_name = params[:project_name]
-
if u.project_id.nil?
p = Project.create(:name=>project_name)
u.project_id = p.id
u.save
-
+ #
# # Testing, add the actions
# urls = ["http://0.0.0.0:3000/website/page1",
# "http://0.0.0.0:3000/website/page2",
@@ -51,16 +50,12 @@ def create
# p.visitors << v
# end
-
-
else
p= Project.find(u.project_id)
end
session[:project_id]= p.id
-
-
- redirect_to project_overview_url(:id => p.id)
+ redirect_to project_index_url
end
end
@@ -1,9 +1,35 @@
class GraphsController < ApplicationController
before_filter :authorize
+ layout "graphs", :except => [:overview, :bello]
-
+ def bello
+ p = Project.find(session[:project_id])
+
+ @project = p
+ bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ #eod = Time.parse("2009-01-29").end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+ eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+
+ conditions = ["created_at > ? AND created_at < ?", "#{bod}", "#{eod}"]
+
+ vs = p.visitors.find(:all,:conditions=>conditions)
+
+ # This data is used to show how to use the line_plot partial
+ @example = [[0,0],[1,1],[2,2]]
+
+
+ # @total_clicks = p.visitors.count(:id,
+ # :group => 'strftime("%Y/%m/%d",created_at)',
+ # :conditions => conditions)
+
+ @total_clicks = vs.group_by { |v|
+ v.created_at.strftime("%Y/%m/%d")
+ }.map{|k,v| [k,v.size]}.sort_by {|date,x| date}
+
+
+ end
# Graphs are created in this method
@@ -46,7 +46,7 @@ def log
hostname = URI.parse(params[:url]).host
if hostname.match(p.name)
puts " >>>>>>>>>>>>>>>>>> HOSTNAME MATCHES with the correct project_id"
- visitor_settings = Tracker.get_settings(params,request)
+ visitor_settings = Tracker.get_settings(params,request,p.name)
if session[:visitor_id]
# Se c''e il visitor_id allora e' conosciuto
# Vedo se l'ultima azione e' stata fatta in meno di mezzo'ora
@@ -1,23 +1,143 @@
class ProjectsController < ApplicationController
before_filter :authorize
+ layout "projects", :except => [ :overview, :visitors,:referrers]
+
-
-
def index
- redirect_to project_overview_url :id=>session[:project_id]
+
+ @project = Project.find(session[:project_id])
+ p = @project
+ bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+
+ conditions = ["created_at > ? AND created_at < ?", "#{bod}", "#{eod}"]
+
+ vs = p.visitors.find(:all,:conditions=>conditions)
+ @total_clicks = p.total_clicks(vs)
+
+ @nvisits = vs.size
+ @page_views =p.page_views(vs)
+ if @page_views == 0
+ @avg_pageviews = 0
+ else
+ @avg_pageviews = "%.2f" % ((@page_views+0.0)/@nvisits)
+ end
+
+ @time_on_site = p.time_on_site(vs)
+ @bounce_rate = "%.2f" % (p.bounce_rate(vs) * 100)
+ @new_visits = "%.2f" % (p.new_visits(vs) * 100)
+ @data_website = p.website_list(vs).first(10)
+
+
+
end
- def overview
- if session[:project_id] == nil
- @project = nil
- else
- @project = Project.find(session[:project_id])
- end
+ # def overview
+ #
+ # redirect_to :action =>"index"
+ # # if session[:project_id] == nil
+ # # @project = nil
+ # # else
+ # # @project = Project.find(session[:project_id])
+ # # p = @project
+ # # bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ # # eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+ # #
+ # # conditions = ["created_at > ? AND created_at < ?", "#{bod}", "#{eod}"]
+ # #
+ # # vs = p.visitors.find(:all,:conditions=>conditions)
+ # # @total_clicks = p.total_clicks(vs)
+ # #
+ # # @nvisits = vs.size
+ # # @page_views = p.page_views(vs)
+ # #
+ # # if @page_views == 0
+ # # @avg_pageviews = 0
+ # # else
+ # # @avg_pageviews = "%.2f" % ((@page_views+0.0)/@nvisits)
+ # # end
+ # #
+ # # @time_on_site = p.time_on_site(vs)
+ # # @bounce_rate = "%.2f" % (p.bounce_rate(vs) * 100)
+ # # @new_visits = "%.2f" % (p.new_visits(vs) * 100)
+ # #
+ # # @data_website = p.website_list(vs)
+ # #
+ # #
+ # # end
+ # end
+ def referrers
+ p = Project.find(session[:project_id])
+ @project = p
+ bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+
+ conditions = ["created_at > ? AND created_at < ?", "#{bod}", "#{eod}"]
+
+ vs = p.visitors.find(:all,:conditions=>conditions)
+ @data_website = p.website_list(vs)
+ @searched_keywords = p.search_engine_queries(vs)
+
+
+
end
+ def visitors
+ p = Project.find(session[:project_id])
+ @project = p
+ bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+ conditions = ["created_at > ? AND created_at < ?", "#{bod}", "#{eod}"]
+
+ vs = p.visitors.find(:all,:conditions=>conditions)
+
+
+
+ @config_os = p.config_os(vs)
+ @browsers = p.browsers(vs)
+ #@hours_by_servertime = p.hours_by_servertime(vs)
+ @config_resolution = p.config_resolution(vs).first(5)
+
+
+ end
+
+ def prova
+ p = Project.find(session[:project_id])
+
+ @project = p
+ bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+
+ conditions = ["created_at > ? AND created_at < ?", "#{bod}", "#{eod}"]
+
+ vs = p.visitors.find(:all,:conditions=>conditions)
+
+
+
+ @total_clicks = p.total_clicks(vs)
+ @config_os = p.config_os(vs)
+ @browsers = p.browsers(vs)
+ @actions = p.visitors_per_action
+ @search_engines = p.search_engines(vs)
+ @time_spent = p.time_spent(vs)
+ @hours_by_servertime = p.hours_by_servertime(vs)
+ @traffic_sources = p.traffic_sources(vs)
+
+
+ @data = p.search_engine_queries(vs)
+ @data_website = p.website_list(vs)
+
+ @nvisits = vs.size
+ @page_views = p.page_views(vs)
+ @avg_pageviews = "%.2f" % ((@page_views+0.0)/@nvisits)
+ @time_on_site = p.time_on_site(vs)
+ @bounce_rate = "%.2f" % (p.bounce_rate(vs) * 100)
+ @new_visits = "%.2f" % (p.new_visits(vs) * 100)
+
+ end
end
@@ -1,6 +1,58 @@
class ReferersController < ApplicationController
before_filter :authorize
+ layout "referers", :except => [:bello]
+
+
+
+ def bello
+ @project = Project.find(session[:project_id])
+ @variabile = 1
+
+ p = @project
+
+
+ bod = Time.parse("2009-01-01").strftime("%Y-%m-%d %H:%M:%S")
+ # eod = Time.parse("2009-01-29").end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+ eod = Time.now.end_of_day.strftime("%Y-%m-%d %H:%M:%S")
+
+ conditions = ["referer_type = ? AND created_at > ? AND created_at < ? AND referer_keyword IS NOT NULL",
+ "1", "#{bod}", "#{eod}"]
+
+
+
+ # @queries = p.visitors.count(:id,
+ # :group => 'referer_keyword',
+ # :conditions => conditions).sort_by{|x,y| y}.reverse
+
+ total_visits = p.visitors.find(:all, :conditions => conditions)
+
+ queries = total_visits.group_by{|v| v.referer_keyword}
+
+ list = []
+
+
+ queries.keys.each do |k|
+ vs = queries[k]
+ nvisitors = queries[k].size
+
+ total_actions = vs.inject(0){|total,v| total + v.total_actions}
+ total_time = vs.inject(0){|total,v| total + v.time_spent}
+ avg_time = (total_time/nvisitors).to_i
+ avg_time = [avg_time/60 % 60, avg_time % 60].map{|t| t.to_s.rjust(2,'0')}.join(':')
+ list << [k,
+ nvisitors,
+ "%.2f" % ((total_actions+0.0)/nvisitors),
+ avg_time
+
+ ]
+
+ end
+ @data = list.sort_by{|q,v,a,t| v}.reverse.first(25)
+
+
+ end
+
def queries
@project = Project.find(session[:project_id])
@variabile = 1
Oops, something went wrong.

0 comments on commit 670e7d7

Please sign in to comment.