counter_culture 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5637cebe0df178e1b1f77843a82f82a08405eb9c82aa82ac30af0dd82c88c91
4
- data.tar.gz: e125436305f7181c9e4aba3d4459b6f83b0f57c41512c20f804d42b9c1f99a79
3
+ metadata.gz: ed37e7ce1d391b9fc468d8a1638b78e6afb46bc764dd7fff6935d00e41dbf18b
4
+ data.tar.gz: 1a7d6b777a4065e214ebab7a25d271c4755eca109ca2907f71363450f329ff03
5
5
  SHA512:
6
- metadata.gz: 4fca0f938a9dd9afc261ba9af247c5e9ba5773e16ec3219274cde22d5c02268555e29a39a8d4bc4e403d05b2dba53aa868e119f804dc3f53a644d17b3aee448d
7
- data.tar.gz: 9de907bfc4baa6746f1072845c66a0ebb6f0c00009a7818ba1b4422a7bf0cd0fbea72544097b85ff3ed1ff262d24e06e5b8c1a95e5237ba97d364394353d78c9
6
+ metadata.gz: '092c9686853ad23dea228cdd32ecef385efeeb3a43f55778372faaf052359512eaf82c7d2f68b1898d419f6911646e2024fde2d75706cefb339b7e98a3c125ce'
7
+ data.tar.gz: cad2c4b3c7546d0a2098f3d738631712aaf80d26cf6244c7b27c53c3358fca7130e4e52c756e29c7b331549875cc063a7b28f1bc810f8556d73bb58ab4fd6cec
@@ -1,3 +1,8 @@
1
+ ## 2.2.1 (April 17, 2019)
2
+
3
+ Improvements:
4
+ - Improve logging when `verbose` is set (#256)
5
+
1
6
  ## 2.2.0 (April 9, 2019)
2
7
 
3
8
  Improvements:
data/README.md CHANGED
@@ -7,7 +7,13 @@ Turbo-charged counter caches for your Rails app. Huge improvements over the Rail
7
7
  * Supports dynamic column names, making it possible to split up the counter cache for different types of objects
8
8
  * Can keep a running count, or a running total
9
9
 
10
- Tested against Ruby 2.2.10, 2.3.7, 2.4.4 and 2.5.1 and against the latest patch releases of Rails 3.2, 4.0, 4.1, 4.2, 5.0, 5.1 and 5.2.
10
+ Tested against Ruby 2.3.8, 2.4.6, 2.5.5 and 2.6.2 and against the latest patch releases of Rails 4.2, 5.0, 5.1 and 5.2.
11
+
12
+ Please note that -- unlike Rails' built-in counter-caches -- counter_culture does not currently change the behavior of the `.size` method on ActiveRecord associations. If you want to avoid a database query and read the cached value, please use the attribute name containing the counter cache directly.
13
+ ```
14
+ product.categories.size # => will lead to a SELECT COUNT(*) query
15
+ product.categories_count # => will use counter cache without query
16
+ ```
11
17
 
12
18
  ## Installation
13
19
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.2.1
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: counter_culture 2.2.0 ruby lib
5
+ # stub: counter_culture 2.2.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "counter_culture".freeze
9
- s.version = "2.2.0"
9
+ s.version = "2.2.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Magnus von Koeller".freeze]
14
- s.date = "2019-04-09"
14
+ s.date = "2019-04-17"
15
15
  s.description = "counter_culture provides turbo-charged counter caches that are kept up-to-date not just on create and destroy, that support multiple levels of indirection through relationships, allow dynamic column names and that avoid deadlocks by updating in the after_commit callback.".freeze
16
16
  s.email = "magnus@vonkoeller.de".freeze
17
17
  s.extra_rdoc_files = [
@@ -123,7 +123,7 @@ Gem::Specification.new do |s|
123
123
  s.homepage = "http://github.com/magnusvk/counter_culture".freeze
124
124
  s.licenses = ["MIT".freeze]
125
125
  s.required_ruby_version = Gem::Requirement.new(">= 2.3.0".freeze)
126
- s.rubygems_version = "3.0.3".freeze
126
+ s.rubygems_version = "2.7.6.2".freeze
127
127
  s.summary = "Turbo-charged counter caches for your Rails app.".freeze
128
128
 
129
129
  if s.respond_to? :specification_version then
@@ -67,7 +67,7 @@ module CounterCulture
67
67
  end
68
68
 
69
69
  def perform
70
- log "Performing reconciling of #{counter.model}##{counter.relation.to_sentence}.\n"
70
+ log "Performing reconciling of #{counter.model}##{counter.relation.to_sentence}."
71
71
  # if we're provided a custom set of column names with conditions, use them; just use the
72
72
  # column name otherwise
73
73
  # which class does this relation ultimately point to? that's where we have to start
@@ -105,14 +105,14 @@ module CounterCulture
105
105
  update_count_for_batch(column_name, records)
106
106
  end
107
107
  end
108
- log "\n"
109
- log "Finished reconciling of #{counter.model}##{counter.relation.to_sentence}.\n"
108
+ log_without_newline "\n"
109
+ log "Finished reconciling of #{counter.model}##{counter.relation.to_sentence}."
110
110
  end
111
111
 
112
112
  private
113
113
 
114
114
  def update_count_for_batch(column_name, records)
115
- log "."
115
+ log_without_newline "."
116
116
 
117
117
  ActiveRecord::Base.transaction do
118
118
  records.each do |record|
@@ -145,6 +145,12 @@ module CounterCulture
145
145
  Rails.logger.info(message)
146
146
  end
147
147
 
148
+ def log_without_newline(message)
149
+ return unless log?
150
+
151
+ Rails.logger << message if Rails.logger.info?
152
+ end
153
+
148
154
  def log?
149
155
  options[:verbose] && Rails.logger
150
156
  end
@@ -1367,13 +1367,17 @@ describe "CounterCulture" do
1367
1367
  SimpleDependent.delete_all
1368
1368
  SimpleMain.delete_all
1369
1369
 
1370
- main = SimpleMain.create
1371
- 3.times { main.simple_dependents.create }
1370
+ 2.times do
1371
+ main = SimpleMain.create
1372
+ 3.times { main.simple_dependents.create }
1373
+ end
1372
1374
 
1373
- SimpleDependent.counter_culture_fix_counts :batch_size => A_BATCH, verbose: true
1375
+ SimpleDependent.counter_culture_fix_counts :batch_size => 1, verbose: true
1374
1376
 
1375
1377
  expect(io.string).to include(
1376
1378
  "Performing reconciling of SimpleDependent#simple_main.")
1379
+ expect(io.string).to include(
1380
+ "..")
1377
1381
  expect(io.string).to include(
1378
1382
  "Finished reconciling of SimpleDependent#simple_main.")
1379
1383
  Rails.logger = logger
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: counter_culture
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus von Koeller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-09 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: after_commit_action
@@ -336,7 +336,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
336
  - !ruby/object:Gem::Version
337
337
  version: '0'
338
338
  requirements: []
339
- rubygems_version: 3.0.3
339
+ rubyforge_project:
340
+ rubygems_version: 2.7.6.2
340
341
  signing_key:
341
342
  specification_version: 4
342
343
  summary: Turbo-charged counter caches for your Rails app.