skinny_jeans 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/skinny_jeans/log_parser.rb +25 -9
- data/skinny_jeans.gemspec +1 -1
- data/test/skinny_jeans_test.rb +1 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
@@ -12,6 +12,11 @@ module SkinnyJeans
|
|
12
12
|
@logfile_path, @sqlite_db_path, @path_regexp, @date_regexp = [logfile_path, sqlite_db_path, path_regexp, date_regexp]
|
13
13
|
@is_gzipped = !logfile_path.to_s[/gz/].nil?
|
14
14
|
SkinnyJeans::prepare_db(@sqlite_db_path)
|
15
|
+
|
16
|
+
# in my tests, setting synchronous=1 (or even 0) had little or no speed gain
|
17
|
+
# but I leave it at one for situations with poor IO
|
18
|
+
SkinnyJeans::SkinnyJeanDb.connection.execute("PRAGMA synchronous=1")
|
19
|
+
|
15
20
|
@hash_of_dates = {}
|
16
21
|
@hash_of_dates_for_keywords = {}
|
17
22
|
@last_datetime = nil
|
@@ -78,9 +83,10 @@ module SkinnyJeans
|
|
78
83
|
|
79
84
|
hash_of_dates.each do |date, hash_of_paths|
|
80
85
|
|
81
|
-
|
86
|
+
Pageview.transaction do
|
87
|
+
realtime = Benchmark.realtime do
|
88
|
+
Spinner::with_spinner(:count=>hash_of_paths.keys.size, :message=>"Inserting rows into database for pageviews #{date}...") do |spin|
|
82
89
|
hash_of_paths.keys.each_with_index do |path, index|
|
83
|
-
# puts "path is #{path}, #{index.to_f/hash_of_paths.keys.size.to_f}"
|
84
90
|
pv = Pageview.find_or_create_by_date_and_path(date, path)
|
85
91
|
pv.pageview_count ||= 0
|
86
92
|
pv.pageview_count += hash_of_paths[path]
|
@@ -88,12 +94,17 @@ module SkinnyJeans
|
|
88
94
|
persisted += 1
|
89
95
|
spin.call
|
90
96
|
end
|
91
|
-
|
92
|
-
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
puts "completed pageviews date #{date.inspect} with #{hash_of_paths.keys.size} keys in #{realtime}"
|
93
102
|
|
94
103
|
end
|
95
104
|
|
96
105
|
hash_of_dates_for_keywords.each do |date, hash_of_paths|
|
106
|
+
PageviewKeyword.transaction do
|
107
|
+
realtime = Benchmark.realtime do
|
97
108
|
Spinner::with_spinner(:count=>hash_of_paths.keys.size, :message=>"Inserting rows into database for pageview_keywords #{date}...") do |spin|
|
98
109
|
hash_of_paths.keys.each do |path|
|
99
110
|
hash_of_paths[path].keys.each do |keyword|
|
@@ -107,7 +118,9 @@ module SkinnyJeans
|
|
107
118
|
spin.call
|
108
119
|
end
|
109
120
|
end
|
110
|
-
|
121
|
+
end
|
122
|
+
end
|
123
|
+
puts "completed pageview_keywords date #{date.inspect} with #{hash_of_paths.keys.size} keys in #{realtime}"
|
111
124
|
end
|
112
125
|
|
113
126
|
end
|
@@ -116,10 +129,13 @@ module SkinnyJeans
|
|
116
129
|
|
117
130
|
Update.create!({:last_pageview_at => self.last_pageview_at, :lines_parsed => lines_parsed, :last_line_parsed => last_line_parsed.to_s[0..254]})
|
118
131
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
132
|
+
puts("total records in DB: #{Pageview.count}
|
133
|
+
lines parsed this round: #{lines_parsed}
|
134
|
+
lines persisted this round:#{persisted}
|
135
|
+
total SkinnyJeans executions since inception: #{Update.count}")
|
136
|
+
puts("vacuuming DB")
|
137
|
+
SkinnyJeans::SkinnyJeanDb.connection.execute("VACUUM")
|
138
|
+
puts("vacuuming complete")
|
123
139
|
|
124
140
|
return self
|
125
141
|
|
data/skinny_jeans.gemspec
CHANGED
data/test/skinny_jeans_test.rb
CHANGED
@@ -8,6 +8,7 @@ class SkinnyJeansTest < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
def test_will_work
|
10
10
|
db_path = File.expand_path(File.dirname(__FILE__) + "/more_sample_data/skinny_jeans_deal_show.db")
|
11
|
+
FileUtils.rm(db_path) if File.exists?(db_path)
|
11
12
|
_logfile_path = File.expand_path(File.dirname(__FILE__) + "/more_sample_data/broken_access_big.log")
|
12
13
|
puts db_path.inspect
|
13
14
|
sj=SkinnyJeans::LogParser.execute(_logfile_path, sqlite_skinny_jeans = db_path, path_regexp = /\s\/deals\/(.*)\sHTTP/, date_regexp = /\[(\d.*\d)\]/)
|