counter_culture 2.9.0 → 3.0.0

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: 99af13953d00540dac3d0b149483d190f03f4c0f77063cdd440b2b18c1ef6031
4
- data.tar.gz: fedce32d590b66c8ff0bf291d612ef1f1fd08356afb81a56ae310caa6a9eeac9
3
+ metadata.gz: 6e21168dbc07960cbb457996e275fe225426b9e96cd4b78a7dcd65ac13a0e006
4
+ data.tar.gz: 655b861dbd102fd40c0be44fc9f12c5a3a8b21682a8951597c7b4d2bcde3ea5e
5
5
  SHA512:
6
- metadata.gz: 510c27a1188f8cbe9073487f2f0f7579ffad46a1b140c44bdfcea07308ddb0975587140dd96a60087475d8c6ad94d1b415cb40f57a1ba59e7d19673bd426bf93
7
- data.tar.gz: 5c2acebf87a92a8ca02e7bd38d4d683cde4fa77c46f611ae29f6007509450baeeb72a69df6107c38606b9243d1e61e5a38302ec51bbd60bdb1fbd8bd53b1289f
6
+ metadata.gz: 42ae36d35f8ad486b25477a89e87477a40909fb08ffd627c6441c2c4ce17ef038c5f92f3514bd2cc993fd01996f3e49ab2470481f2ab778dc620c2aa7f65d59c
7
+ data.tar.gz: 48ad4871eb41b4a97e5f53f41a671e4fef455fa2c70d475002de69bda1db8b1e8cc4af91b0c251d6ac1a4fba961ba5ab3eb2e821f9e9c8735a577728f7270338
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ dist: focal
1
2
  language: ruby
2
3
  cache:
3
4
  directories:
@@ -9,34 +10,37 @@ branches:
9
10
  only:
10
11
  - master
11
12
  addons:
12
- postgresql: "9.6"
13
+ postgresql: '12'
14
+ apt:
15
+ packages:
16
+ - postgresql-12
17
+ - postgresql-client-12
13
18
  rvm:
14
- - "2.5.9"
15
19
  - "2.6.8"
16
20
  - "2.7.4"
17
21
  - "3.0.2"
18
22
  gemfile:
19
- - gemfiles/rails_4.2.gemfile
20
- - gemfiles/rails_5.0.gemfile
21
- - gemfiles/rails_5.1.gemfile
22
23
  - gemfiles/rails_5.2.gemfile
23
24
  - gemfiles/rails_6.0.gemfile
24
25
  - gemfiles/rails_6.1.gemfile
25
26
  matrix:
26
27
  exclude:
27
- - rvm: "3.0.1"
28
- gemfile: gemfiles/rails_4.2.gemfile
29
- - rvm: "3.0.1"
30
- gemfile: gemfiles/rails_5.0.gemfile
31
- - rvm: "3.0.1"
32
- gemfile: gemfiles/rails_5.1.gemfile
33
- - rvm: "3.0.1"
28
+ - rvm: "3.0.2"
34
29
  gemfile: gemfiles/rails_5.2.gemfile
35
30
  env:
31
+ global:
32
+ - PGUSER=postgres
33
+ - PGPORT=5432
34
+ - PGHOST=localhost
35
+ jobs:
36
36
  - DB=postgresql
37
37
  - DB=sqlite3
38
38
  - DB=mysql2
39
39
  before_install:
40
+ - sudo sed -i -e '/local.*peer/s/postgres/all/' -e 's/peer\|md5/trust/g' /etc/postgresql/*/main/pg_hba.conf
41
+ - sudo service postgresql restart
42
+ - sleep 1
43
+ - postgres --version
40
44
  - if [ "$BUNDLE_GEMFILE" = "$PWD/gemfiles/rails_4.2.gemfile" ]; then gem install bundler -v '1.17.3'; else gem install bundler -v '> 2'; fi
41
45
  install:
42
46
  - if [ "$BUNDLE_GEMFILE" = "$PWD/gemfiles/rails_4.2.gemfile" ]; then bundle _1.17.3_ update; else bundle update; fi
data/Appraisals CHANGED
@@ -1,7 +1,4 @@
1
1
  %w[
2
- 4.2
3
- 5.0
4
- 5.1
5
2
  5.2
6
3
  6.0
7
4
  6.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 3.0.0 (October 26, 2021)
2
+
3
+ Breaking changes:
4
+ - Dropped support for Ruby < 2.6
5
+ - Dropped support for Rails < 5.2
6
+
7
+ Note that there are no specific breaking changes that would cause older
8
+ versions of Ruby or Rails to stop working, we have simply stopped testing
9
+ against them.
10
+
11
+ Improvements:
12
+ - Support PostgreSql's `money` type for use with a delta column (#333)
13
+
1
14
  ## 2.9.0 (August 27, 2021)
2
15
 
3
16
  Improvements:
data/Gemfile CHANGED
@@ -4,6 +4,3 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify the gem's dependencies in counter_culture.gemspec
6
6
  gemspec
7
-
8
- # Ensure we have the default DB adapter for testing
9
- gem 'sqlite3'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # counter_culture [![Build Status](https://travis-ci.com/magnusvk/counter_culture.svg)](https://travis-ci.com/magnusvk/counter_culture)
1
+ # counter_culture [![Build Status](https://app.travis-ci.com/magnusvk/counter_culture.svg?branch=master)](https://app.travis-ci.com/magnusvk/counter_culture)
2
2
 
3
3
  Turbo-charged counter caches for your Rails app. Huge improvements over the Rails standard counter caches:
4
4
 
@@ -69,10 +69,16 @@ module CounterCulture
69
69
  "#{model.connection.quote_column_name(change_counter_column)}"
70
70
  end
71
71
 
72
+ column_type = klass.type_for_attribute(change_counter_column).type
73
+
72
74
  # we don't use Rails' update_counters because we support changing the timestamp
73
75
  updates = []
74
76
  # this updates the actual counter
75
- updates << "#{quoted_column} = COALESCE(#{quoted_column}, 0) #{operator} #{delta_magnitude}"
77
+ if column_type == :money
78
+ updates << "#{quoted_column} = COALESCE(CAST(#{quoted_column} as NUMERIC), 0) #{operator} #{delta_magnitude}"
79
+ else
80
+ updates << "#{quoted_column} = COALESCE(#{quoted_column}, 0) #{operator} #{delta_magnitude}"
81
+ end
76
82
  # and here we update the timestamp, if so desired
77
83
  if touch
78
84
  current_time = obj.send(:current_time_from_proper_timezone)
@@ -187,7 +187,12 @@ module CounterCulture
187
187
  # if a delta column is provided use SUM, otherwise use COUNT
188
188
  return @count_select if @count_select
189
189
  if delta_column
190
- @count_select = "SUM(COALESCE(#{self_table_name}.#{delta_column},0))"
190
+ # cast the column as NUMERIC if it is a PG money type
191
+ if model.type_for_attribute(delta_column).type == :money
192
+ @count_select = "SUM(COALESCE(CAST(#{self_table_name}.#{delta_column} as NUMERIC),0))"
193
+ else
194
+ @count_select = "SUM(COALESCE(#{self_table_name}.#{delta_column}, 0))"
195
+ end
191
196
  else
192
197
  @count_select = "COUNT(#{self_table_name}.#{model.primary_key})*#{delta_magnitude}"
193
198
  end
@@ -1,3 +1,3 @@
1
1
  module CounterCulture
2
- VERSION = '2.9.0'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
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.9.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus von Koeller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-27 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -272,9 +272,6 @@ files:
272
272
  - Rakefile
273
273
  - circle.yml
274
274
  - counter_culture.gemspec
275
- - gemfiles/rails_4.2.gemfile
276
- - gemfiles/rails_5.0.gemfile
277
- - gemfiles/rails_5.1.gemfile
278
275
  - gemfiles/rails_5.2.gemfile
279
276
  - gemfiles/rails_6.0.gemfile
280
277
  - gemfiles/rails_6.1.gemfile
@@ -1,11 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sqlite3", "~> 1.3.0"
6
- gem "rails", "~> 4.2.0"
7
- gem "pg", "~> 0.15"
8
- gem "mysql2"
9
- gem "bigdecimal", "~> 1.3.5"
10
-
11
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sqlite3", "~> 1.3.0"
6
- gem "rails", "~> 5.0.0"
7
- gem "pg"
8
- gem "mysql2"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sqlite3", "~> 1.3.0"
6
- gem "rails", "~> 5.1.0"
7
- gem "pg"
8
- gem "mysql2"
9
-
10
- gemspec path: "../"