rail_stat_generator 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/templates/app/controllers/rail_stat_controller.rb +126 -111
- data/templates/app/helpers/rail_stat_helper.rb +13 -14
- data/templates/app/models/iptoc.rb +3 -1
- data/templates/app/models/rail_stat.rb +256 -130
- data/templates/app/models/search_term.rb +6 -4
- data/templates/app/views/rail_stat/hits.rhtml +30 -19
- data/templates/app/views/rail_stat/lang.rhtml +24 -12
- data/templates/app/views/rail_stat/other.rhtml +49 -24
- data/templates/app/views/rail_stat/path.rhtml +13 -15
- data/templates/app/views/rail_stat/platform.rhtml +26 -10
- data/templates/app/views/rail_stat/refs.rhtml +21 -9
- data/templates/db/railstat.mysql.sql +44 -43
- data/templates/db/railstat.pgsql.sql +47 -46
- data/templates/lib/path_tracker.rb +6 -3
- metadata +3 -2
@@ -1,111 +1,126 @@
|
|
1
|
-
require_dependency 'path_tracker'
|
2
|
-
|
3
|
-
class RailStatController < ApplicationController
|
4
|
-
include PathTracker
|
5
|
-
|
6
|
-
before_filter :extract_subdomain
|
7
|
-
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@
|
23
|
-
@
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@
|
29
|
-
@
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if(
|
85
|
-
|
86
|
-
|
87
|
-
else
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
1
|
+
require_dependency 'path_tracker'
|
2
|
+
|
3
|
+
class RailStatController < ApplicationController
|
4
|
+
include PathTracker
|
5
|
+
|
6
|
+
before_filter :extract_subdomain
|
7
|
+
|
8
|
+
def index
|
9
|
+
redirect_to(:action=>'path')
|
10
|
+
end
|
11
|
+
|
12
|
+
def path
|
13
|
+
@ordered_resources, @orarr = RailStat.get_ordered40resources(@subdomain)
|
14
|
+
|
15
|
+
@number_hits = (@params['nh'] or not @params['nh'].nil?) ? @params['nh'].to_i : 50
|
16
|
+
@include_search_engines = ((@params['ise'] == '' or @params['ise'] == "1") ? 1 : 0)
|
17
|
+
|
18
|
+
@count_totals = RailStat.resource_count_totals
|
19
|
+
@paths = RailStat.find_all_by_flag(@include_search_engines == 0, @number_hits, @subdomain)
|
20
|
+
|
21
|
+
# Experiments:
|
22
|
+
@total_hits = RailStat.count_hits(:subdomain => @subdomain)
|
23
|
+
@unique_hits = RailStat.count_hits(:unique, :subdomain => @subdomain)
|
24
|
+
end
|
25
|
+
|
26
|
+
def hits
|
27
|
+
@lastweek = RailStat.find_by_days(:subdomain=>@subdomain, :days => 7)
|
28
|
+
@first_hit = RailStat.find_first_hit(:subdomain=>@subdomain)
|
29
|
+
@total_hits = RailStat.count_hits(:subdomain => @subdomain)
|
30
|
+
@unique_hits = RailStat.count_hits(:unique, :subdomain => @subdomain)
|
31
|
+
n = Time.now
|
32
|
+
d = Date.new(n.year, n.month, n.day)
|
33
|
+
@today_total = RailStat.count_hits(:subdomain => @subdomain, :date => d)
|
34
|
+
@today_unique = RailStat.count_hits(:unique, :subdomain => @subdomain, :date => d)
|
35
|
+
@past_7_total = RailStat.count_hits(:subdomain => @subdomain, :past_days => 7)
|
36
|
+
@past_7_unique = RailStat.count_hits(:unique, :subdomain => @subdomain, :past_days => 7)
|
37
|
+
end
|
38
|
+
|
39
|
+
def platform
|
40
|
+
@total_hits = RailStat.count_hits(:subdomain => @subdomain)
|
41
|
+
@platforms = RailStat.find_by_platform(:subdomain => @subdomain)
|
42
|
+
@browsers = RailStat.find_by_browser(:subdomain => @subdomain)
|
43
|
+
end
|
44
|
+
|
45
|
+
def lang
|
46
|
+
@total_hits = RailStat.count_hits(:subdomain => @subdomain)
|
47
|
+
@languages = RailStat.find_by_language(:subdomain => @subdomain)
|
48
|
+
@countries = RailStat.find_by_country(:subdomain => @subdomain)
|
49
|
+
end
|
50
|
+
|
51
|
+
def refs
|
52
|
+
@refs = RailStat.find_by_domain(:subdomain => @subdomain)
|
53
|
+
@searchterms = SearchTerm.find_grouped(:subdomain => @subdomain)
|
54
|
+
end
|
55
|
+
|
56
|
+
def other
|
57
|
+
#hits = RailStat.count_hits(:subdomain => @subdomain)
|
58
|
+
#@total_hits = RailStat.count_hits()
|
59
|
+
|
60
|
+
@flash_clients = RailStat.find_by_client(:type => "flash", :subdomain => @subdomain)
|
61
|
+
@flash_clients_total = @flash_clients.inject(0) {|sum, result| sum + result.total.to_i}
|
62
|
+
|
63
|
+
@java_clients = RailStat.find_by_client(:type => "java_enabled", :subdomain => @subdomain)
|
64
|
+
@java_clients_total = @java_clients.inject(0) {|sum, result| sum + result.total.to_i}
|
65
|
+
|
66
|
+
@javascript_clients = RailStat.find_by_client(:type => "java", :subdomain => @subdomain)
|
67
|
+
@javascript_clients_total = @javascript_clients.inject(0) {|sum, result| sum + result.total.to_i}
|
68
|
+
|
69
|
+
@width_of_clients = RailStat.find_by_client(:type => "screen_size", :subdomain => @subdomain)
|
70
|
+
@width_of_clients_total = @width_of_clients.inject(0) {|sum, result| sum + result.total.to_i}
|
71
|
+
|
72
|
+
@colors_of_clients = RailStat.find_by_client(:type => "colors", :subdomain => @subdomain)
|
73
|
+
@colors_of_clients_total = @colors_of_clients.inject(0) {|sum, result| sum + result.total.to_i}
|
74
|
+
end
|
75
|
+
|
76
|
+
def tracker_js
|
77
|
+
if @request.env['HTTP_REFERER'] and @request.env['HTTP_REFERER'].include?(@request.env['HTTP_HOST'])
|
78
|
+
str = <<-JSDATA
|
79
|
+
c=0;
|
80
|
+
s=0;
|
81
|
+
n=navigator;
|
82
|
+
d=document;
|
83
|
+
plugin=(n.mimeTypes&&n.mimeTypes["application/x-shockwave-flash"])?n.mimeTypes["application/x-shockwave-flash"].enabledPlugin:0;
|
84
|
+
if(plugin) {
|
85
|
+
w=n.plugins["Shockwave Flash"].description.split("");
|
86
|
+
for(i=0;i<w.length;++i) { if(!isNaN(parseInt(w[i]))) { f=w[i];break; } }
|
87
|
+
} else if(n.userAgent&&n.userAgent.indexOf("MSIE")>=0&&(n.appVersion.indexOf("Win")!=-1)) {
|
88
|
+
d.write('<script language="VBScript">On Error Resume Next\\nFor f=10 To 1 Step-1\\nv=IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash."&f))\\nIf v Then Exit For\\nNext\\n</script>');
|
89
|
+
} if(typeof(top.document)=="object"){
|
90
|
+
t=top.document;
|
91
|
+
rf=escape(t.referrer);
|
92
|
+
pd=escape(t.URL);
|
93
|
+
} else {
|
94
|
+
x=window;
|
95
|
+
for(i=0;i<20&&typeof(x.document)=="object";i++) { rf=escape(x.document.referrer); x=x.parent; }
|
96
|
+
pd=0;
|
97
|
+
}
|
98
|
+
d.write('<script language="JavaScript1.2">c=screen.colorDepth;s=screen.width;</script>');
|
99
|
+
if(typeof(f)=='undefined') f=0;
|
100
|
+
d.write('<a href="/" target="_blank"><img src="/rail_stat/track?size='+s+'&colors='+c+'&referer='+rf+'&java=1&je='+(n.javaEnabled()?1:0)+'&doc='+escape(d.URL)+'&flash='+f+'" border="0" width="1" height="1"></a><br>');
|
101
|
+
JSDATA
|
102
|
+
else
|
103
|
+
str = ""
|
104
|
+
end
|
105
|
+
render_text(str)
|
106
|
+
end
|
107
|
+
|
108
|
+
def track
|
109
|
+
track_path
|
110
|
+
@response.headers['Pragma'] = ' '
|
111
|
+
@response.headers['Cache-Control'] = ' '
|
112
|
+
@response.headers['Content-Length'] = 68
|
113
|
+
@response.headers['Accept-Ranges'] = 'bytes'
|
114
|
+
@response.headers['Content-type'] = 'image/gif'
|
115
|
+
@response.headers['Content-Disposition'] = 'inline'
|
116
|
+
File.open("#{RAILS_ROOT}/public/images/railstat/1pxtr.gif", 'rb') { |file| render :text => file.read }
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
private
|
121
|
+
def extract_subdomain
|
122
|
+
@subdomain = ((@request.subdomains and @request.subdomains.first) ? @request.subdomains.first : nil)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
@@ -115,19 +115,18 @@ module RailStatHelper
|
|
115
115
|
"ji" => "Yiddish",
|
116
116
|
"zu" => "Zulu"}
|
117
117
|
|
118
|
-
def
|
119
|
-
@
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
return "odd" if @itClass%2 == 1
|
118
|
+
def alternator
|
119
|
+
if @alternator.nil?
|
120
|
+
@alternator = 1
|
121
|
+
end
|
122
|
+
|
123
|
+
@alternator = -@alternator
|
124
|
+
|
125
|
+
if @alternator == -1
|
126
|
+
return "even"
|
127
|
+
else
|
128
|
+
return "odd"
|
129
|
+
end
|
131
130
|
end
|
132
131
|
|
133
132
|
def get_path_image(path, ors)
|
@@ -175,7 +174,7 @@ module RailStatHelper
|
|
175
174
|
end
|
176
175
|
|
177
176
|
def path_version_data(value)
|
178
|
-
return '
|
177
|
+
return 'Unknown' if value.nil?
|
179
178
|
return 'Unsupported' if value == "0"
|
180
179
|
return 'Supports' if value == "1"
|
181
180
|
return value
|
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'ipaddr'
|
1
2
|
class Iptoc < ActiveRecord::Base
|
2
3
|
def self.find_by_ip_address(ip_address)
|
3
|
-
|
4
|
+
ip = IPAddr.new(ip_address)
|
5
|
+
find(:first, :conditions => ["IP_FROM <= ? AND IP_TO >= ?", ip.to_i, ip.to_i])
|
4
6
|
end
|
5
7
|
end
|