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 CHANGED
@@ -1 +1 @@
1
- 0.7.1
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
- Spinner::with_spinner(:count=>hash_of_paths.keys.size, :message=>"Inserting rows into database for pageviews #{date}...") do |spin|
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
- end
92
- puts "completed pageviews date #{date.inspect} with #{hash_of_paths.keys.size} keys"
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
- puts "completed pageview_keywords date #{date.inspect} with #{hash_of_paths.keys.size} keys"
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
- puts("total records in DB: #{Pageview.count}
120
- lines parsed this round: #{lines_parsed}
121
- lines persisted this round:#{persisted}
122
- total SkinnyJeans executions since inception: #{Update.count}")
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{skinny_jeans}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jonathan Otto"]
@@ -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)\]/)
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 7
8
- - 1
9
- version: 0.7.1
7
+ - 8
8
+ - 0
9
+ version: 0.8.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Otto