simple_record 1.4.3 → 1.4.4

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/lib/simple_record.rb CHANGED
@@ -68,6 +68,7 @@ module SimpleRecord
68
68
  def log_usage(types={})
69
69
  return if types.nil?
70
70
  types.each_pair do |type, options|
71
+ options[:lines_between_flushes] = 100 unless options[:lines_between_flushes]
71
72
  @@usage_logging_options[type] = options
72
73
  end
73
74
  end
@@ -855,7 +856,7 @@ module SimpleRecord
855
856
  results = q_type == :all ? [] : nil
856
857
  begin
857
858
  results=find_with_metadata(*params)
858
- puts "RESULT=" + results.inspect
859
+ # puts "RESULT=" + results.inspect
859
860
  write_usage(:select, domain, q_type, options, results)
860
861
  #puts 'params3=' + params.inspect
861
862
  SimpleRecord.stats.selects += 1
@@ -372,9 +372,9 @@ module SimpleRecord
372
372
  options[:conditions] = build_conditions(options[:conditions])
373
373
  # join ids condition and user defined conditions
374
374
  options[:conditions] = options[:conditions].blank? ? ids_cond : "(#{options[:conditions]}) AND #{ids_cond}"
375
- puts 'options=' + options.inspect
375
+ # puts 'options=' + options.inspect
376
376
  result = sql_select(options)
377
- puts 'select_from_ids result=' + result.inspect
377
+ # puts 'select_from_ids result=' + result.inspect
378
378
  # if one record was requested then return it
379
379
  unless bunch_of_records_requested
380
380
  record = result[:items].first
@@ -4,6 +4,7 @@ module SimpleRecord
4
4
 
5
5
  module Logging
6
6
 
7
+
7
8
  module ClassMethods
8
9
  def write_usage(type, domain, q_type, params, results)
9
10
  # puts 'params=' + params.inspect
@@ -20,8 +21,10 @@ module SimpleRecord
20
21
  line = usage_line(type_options[:format], [type, domain, q_type, conditions, params[:order]], results[:request_id], results[:box_usage])
21
22
  file.puts line
22
23
  type_options[:lines] = type_options[:lines] ? type_options[:lines] + 1 : 1
23
- if type_options[:lines] % 100 == 0
24
+ if type_options[:lines] % type_options[:lines_between_flushes] == 0
25
+ # puts "flushing to file..."
24
26
  file.flush
27
+ # sleep 20
25
28
  end
26
29
  # puts 'line=' + line
27
30
  end
@@ -19,7 +19,7 @@ module SimpleRecord
19
19
  @items = results[:items]
20
20
  @currentset_items = results[:items]
21
21
  @next_token = next_token
22
- puts 'bu=' + results[:box_usage]
22
+ # puts 'bu=' + results[:box_usage]
23
23
  @box_usage = results[:box_usage].to_f
24
24
  @request_id = results[:request_id]
25
25
  @options = @params[1]
data/test/test_usage.rb CHANGED
@@ -19,7 +19,7 @@ class TestUsage < TestBase
19
19
  # ensures that it uses next token and what not
20
20
  def test_select_usage_logging
21
21
 
22
- SimpleRecord.log_usage(:select=>{:filename=>"/mnt/selects.csv", :format=>:csv})
22
+ SimpleRecord.log_usage(:select=>{:filename=>"/mnt/selects.csv", :format=>:csv, :lines_between_flushes=>2})
23
23
 
24
24
  num_made = 10
25
25
  num_made.times do |i|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_record
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 3
10
- version: 1.4.3
9
+ - 4
10
+ version: 1.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Travis Reeder
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-07-16 00:00:00 -07:00
20
+ date: 2010-07-18 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency