skinny_jeans 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.4
1
+ 0.6.5
@@ -46,12 +46,21 @@ module SkinnyJeans
46
46
  lineno += 1
47
47
  next if lineno_of_last_line_parsed && lineno <= lineno_of_last_line_parsed
48
48
 
49
- path_match = line[@path_regexp, 1]
50
- next if path_match.nil?
51
- date_match = line[@date_regexp, 1]
52
- next if date_match.nil?
53
- datetime_obj = parse_string_as_date(date_match)
54
-
49
+ begin
50
+ path_match = line[@path_regexp, 1]
51
+ next if path_match.nil?
52
+ date_match = line[@date_regexp, 1]
53
+ next if date_match.nil?
54
+ datetime_obj = parse_string_as_date(date_match)
55
+ rescue ArgumentError => e
56
+ if e.message.match(/invalid byte sequence in UTF-8/)
57
+ puts "failed to parse the following line because of #{e.class.name}: #{e.message}"
58
+ puts line
59
+ next
60
+ else
61
+ raise(e)
62
+ end
63
+ end
55
64
  next if lineno_of_last_line_parsed.nil? && !last_pageview_at.nil? && datetime_obj < last_pageview_at
56
65
 
57
66
  insert_or_increment(datetime_obj, path_match, SkinnyJeans::StringParser.extract_search_query(line))
@@ -68,7 +77,9 @@ module SkinnyJeans
68
77
  realtime = Benchmark.realtime do
69
78
 
70
79
  hash_of_dates.each do |date, hash_of_paths|
71
- hash_of_paths.keys.each do |path|
80
+ puts "on date #{date.inspect} with #{hash_of_paths.keys.size} keys"
81
+ hash_of_paths.keys.each_with_index do |path, index|
82
+ # puts "path is #{path}, #{index.to_f/hash_of_paths.keys.size.to_f}"
72
83
  pv = Pageview.find_or_create_by_date_and_path(date, path)
73
84
  pv.pageview_count ||= 0
74
85
  pv.pageview_count += hash_of_paths[path]
@@ -76,7 +87,7 @@ module SkinnyJeans
76
87
  persisted += 1
77
88
  end
78
89
  end
79
-
90
+ # puts "now doing osk"
80
91
  hash_of_dates_for_keywords.each do |date, hash_of_paths|
81
92
  hash_of_paths.keys.each do |path|
82
93
  hash_of_paths[path].keys.each do |keyword|
@@ -5,7 +5,6 @@ require 'pp'
5
5
 
6
6
  class SkinnyJeans::StringParserTest < Test::Unit::TestCase
7
7
 
8
-
9
8
  def test_can_get_all_urls_from_string
10
9
  _string=<<-EOF
11
10
  98.244.200.209 - - [01/Dec/2010:11:51:26 -0800] "GET /deals/apple-ipod-touch HTTP/1.1" 200 11448 "http://www.google.com/m/search?oe=UTF-8&client=safari&hl=en&q=best+deals+for+the+4th+generation+iPod+touch+32+gb&gws_link_params=spell:1&ei=aqb2TJDBLqGutgfp862NAg&ved=0CBEQBSgA" "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7" "-"
@@ -6,6 +6,13 @@ require 'pp'
6
6
  class SkinnyJeansTest < Test::Unit::TestCase
7
7
 
8
8
 
9
+ def test_will_work
10
+ db_path = File.expand_path(File.dirname(__FILE__) + "/more_sample_data/skinny_jeans_deal_show.db")
11
+ _logfile_path = File.expand_path(File.dirname(__FILE__) + "/more_sample_data/broken_access_big.log")
12
+ puts db_path.inspect
13
+ sj=SkinnyJeans::LogParser.execute(_logfile_path, sqlite_skinny_jeans = db_path, path_regexp = /\s\/deals\/(.*)\sHTTP/, date_regexp = /\[(\d.*\d)\]/)
14
+ end
15
+
9
16
  def test_can_parse_default_nginx_log_format
10
17
  db_path = File.expand_path(File.dirname(__FILE__) + "/skinny_jeans_test.db")
11
18
  FileUtils.rm(db_path) if File.exists?(db_path)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 4
9
- version: 0.6.4
8
+ - 5
9
+ version: 0.6.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Otto
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-13 00:00:00 -06:00
17
+ date: 2011-03-15 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency