unread 0.10.1 → 0.11.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: 05b6ec999b0b08aecbed6fc07c6e1d8e24fa5220d9b360b1fb6a1aa7293cbadc
4
- data.tar.gz: be06fff51e62ecdaeddb2d5d86e89c950c3080db70dbed8b4736d976e17ab1a5
3
+ metadata.gz: da2c0da709d4464ceda393f45c8fa5aa6858c3bf458cbd75351491145a9b4905
4
+ data.tar.gz: b6a4938837521be8b1a86e38aa2b181572cf4ec2731b765389e71538a3822a0a
5
5
  SHA512:
6
- metadata.gz: 9b0c1ac98cdf02095d66c6b77959a039083f5dc9e0a5d350aff8274ba9d6589cf873a46872a32c9a09080bc52f5dce4ab4fcf9450fbe0f4088f2efe6bec80224
7
- data.tar.gz: '0879f93f42eee16f150e64bce7a1271dce8dc5c728f1ece62d7da2ed8c47d7d034c98a7a3619564fb6f8e4a4d35e7e111d123c0dad6e7e0234328e73b47321da'
6
+ metadata.gz: 9b3980715732e4f3dc0fbf2e63b3367322b6f3c03ced30516b6cba94e31e4b54e6a707ae192e4aa5a00fd2ad83b3501c93ba7f89c3d9081903fc36966a183765
7
+ data.tar.gz: '0228314b73218e74d9583860892b77d9fd1f9ed3f41ff9c07b6985095e895be1b609fb4ac9befa34b64c3352b45ffb0c229295e74c1d16e7fdfaf7c7b6e34ee4'
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.9
4
- - 2.3.6
5
- - 2.4.3
6
- - 2.5.0
3
+ - 2.4.6
4
+ - 2.5.5
5
+ - 2.6.3
7
6
  gemfile:
7
+ - gemfiles/rails_6_0.gemfile
8
8
  - gemfiles/rails_5_2.gemfile
9
9
  - gemfiles/rails_5_1.gemfile
10
10
  - gemfiles/rails_5_0.gemfile
@@ -13,13 +13,19 @@ gemfile:
13
13
  - gemfiles/rails_4_0.gemfile
14
14
  matrix:
15
15
  exclude:
16
- - rvm: 2.4.3
16
+ - rvm: 2.4.6
17
17
  gemfile: gemfiles/rails_4_0.gemfile
18
- - rvm: 2.4.3
18
+ - rvm: 2.4.6
19
19
  gemfile: gemfiles/rails_4_1.gemfile
20
- - rvm: 2.5.0
20
+ - rvm: 2.4.6
21
+ gemfile: gemfiles/rails_6_0.gemfile
22
+ - rvm: 2.5.5
21
23
  gemfile: gemfiles/rails_4_0.gemfile
22
- - rvm: 2.5.0
24
+ - rvm: 2.5.5
25
+ gemfile: gemfiles/rails_4_1.gemfile
26
+ - rvm: 2.6.3
27
+ gemfile: gemfiles/rails_4_0.gemfile
28
+ - rvm: 2.6.3
23
29
  gemfile: gemfiles/rails_4_1.gemfile
24
30
  before_install: gem update bundler
25
31
  sudo: false
@@ -27,7 +33,12 @@ env:
27
33
  - DB=sqlite
28
34
  - DB=mysql
29
35
  - DB=postgres
36
+ services:
37
+ - mysql
38
+ - postgres
30
39
  before_script:
31
40
  - gem update --system # https://github.com/travis-ci/travis-ci/issues/8978
32
41
  - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS unread_test;'; fi"
33
42
  - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database unread_test;' -U postgres; fi"
43
+ addons:
44
+ postgresql: "9.4"
data/Appraisals CHANGED
@@ -1,29 +1,48 @@
1
+ appraise "rails-6-0" do
2
+ gem "activerecord", "~> 6.0.0.beta3"
3
+ gem "mysql2", ">= 0.4.4"
4
+ gem "pg", ">= 0.18", "< 2.0"
5
+ gem "sqlite3", "~> 1.4"
6
+ end
7
+
1
8
  appraise "rails-5-2" do
2
- gem "activerecord", "~> 5.2.0.beta2"
3
- gem "mysql2", ">= 0.3.18", "< 0.5", "!= 0.4.3"
9
+ gem "activerecord", "~> 5.2.3"
10
+ gem "mysql2", ">= 0.4.4", "< 0.6.0"
11
+ gem "pg", ">= 0.18", "< 2.0"
12
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
4
13
  end
5
14
 
6
15
  appraise "rails-5-1" do
7
- gem "activerecord", "~> 5.1.0"
8
- gem 'mysql2', '>= 0.3.18', '< 0.5'
16
+ gem "activerecord", "~> 5.1.7"
17
+ gem "mysql2", ">= 0.3.18", "< 0.6.0"
18
+ gem "pg", ">= 0.18", "< 2.0"
19
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
9
20
  end
10
21
 
11
22
  appraise "rails-5-0" do
12
- gem "activerecord", "~> 5.0.0"
13
- gem 'mysql2', '>= 0.3.18', '< 0.5'
23
+ gem "activerecord", "~> 5.0.7"
24
+ gem 'mysql2', '>= 0.3.18', '< 0.6.0'
25
+ gem "pg", ">= 0.18", "< 2.0"
26
+ gem 'sqlite3', '~> 1.3.6'
14
27
  end
15
28
 
16
29
  appraise "rails-4-2" do
17
- gem "activerecord", "~> 4.2.5"
18
- gem 'mysql2', '>= 0.3.13', '< 0.5'
30
+ gem "activerecord", "~> 4.2.11"
31
+ gem 'mysql2', '>= 0.3.13', '< 0.6.0'
32
+ gem "pg", "~> 0.15"
33
+ gem 'sqlite3', '~> 1.3.6'
19
34
  end
20
35
 
21
36
  appraise "rails-4-1" do
22
- gem "activerecord", "~> 4.1.14"
23
- gem "mysql2", '~> 0.3.13'
37
+ gem "activerecord", "~> 4.1.16"
38
+ gem 'mysql2', '~> 0.3.13'
39
+ gem "pg", "~> 0.11"
40
+ gem 'sqlite3', '~> 1.3.6'
24
41
  end
25
42
 
26
43
  appraise "rails-4-0" do
27
44
  gem "activerecord", "~> 4.0.13"
28
45
  gem "mysql2", '~> 0.3.10'
46
+ gem "pg", "~> 0.11"
47
+ gem 'sqlite3', '~> 1.3.6'
29
48
  end
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2010-2018 Georg Ledermann
3
+ Copyright (c) 2010-2019 Georg Ledermann
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -19,8 +19,8 @@ Ruby gem to manage read/unread status of ActiveRecord objects - and it's fast.
19
19
 
20
20
  ## Requirements
21
21
 
22
- * Ruby 2.2 or newer
23
- * Rails 4.0 or newer (including Rails 5.1 and 5.2)
22
+ * Ruby 2.4 or newer
23
+ * Rails 4.0 or newer (including Rails 6)
24
24
  * MySQL, PostgreSQL or SQLite
25
25
  * Needs a timestamp field in your models (like created_at or updated_at) with a database index on it
26
26
 
@@ -160,6 +160,30 @@ users[1].have_read?(message2)
160
160
  Message.cleanup_read_marks!
161
161
  ```
162
162
 
163
+ ## Getting read/unread stats through a relationship
164
+
165
+ ```ruby
166
+ class Document < ApplicationRecord
167
+ has_many :comments
168
+ end
169
+
170
+ class Comment < ApplicationRecord
171
+ acts_as_readable on: :created_at
172
+ belongs_to :document
173
+ end
174
+
175
+ # Get unread comments count for a document
176
+ document = Document.find(1)
177
+ default_hash = Hash.new { |h, k| h[k] = { unread: 0, total: 0 } }
178
+ document.comments.with_read_marks_for(current_user).reduce(default_hash) do |hash, comment|
179
+ hash[comment.id][:unread] += 1 if comment.unread?(current_user)
180
+ hash[comment.id][:total] += 1
181
+ hash
182
+ end
183
+ # => {20=>{:unread=>1, :total=>10}, 82=>{:unread=>0, :total=>4}
184
+ ```
185
+
186
+ Using `with_read_marks_for` here is the key. It uses just one query and makes sure that the following `unread?` invocations use the result of the first query.
163
187
 
164
188
  ## How does it work?
165
189
 
@@ -199,4 +223,4 @@ AND messages.created_at > '2010-10-20 08:50:00'
199
223
  Hint: You should add a database index on `messages.created_at`.
200
224
 
201
225
 
202
- Copyright (c) 2010-2018 [Georg Ledermann](http://www.georg-ledermann.de) and [contributors](https://github.com/ledermann/unread/graphs/contributors), released under the MIT license
226
+ Copyright (c) 2010-2019 [Georg Ledermann](http://www.georg-ledermann.de) and [contributors](https://github.com/ledermann/unread/graphs/contributors), released under the MIT license
@@ -4,5 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "activerecord", "~> 4.0.13"
6
6
  gem "mysql2", "~> 0.3.10"
7
+ gem "pg", "~> 0.11"
8
+ gem "sqlite3", "~> 1.3.6"
7
9
 
8
10
  gemspec path: "../"
@@ -2,7 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 4.1.14"
5
+ gem "activerecord", "~> 4.1.16"
6
6
  gem "mysql2", "~> 0.3.13"
7
+ gem "pg", "~> 0.11"
8
+ gem "sqlite3", "~> 1.3.6"
7
9
 
8
10
  gemspec path: "../"
@@ -2,7 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 4.2.5"
6
- gem "mysql2", ">= 0.3.13", "< 0.5"
5
+ gem "activerecord", "~> 4.2.11"
6
+ gem "mysql2", ">= 0.3.13", "< 0.6.0"
7
+ gem "pg", "~> 0.15"
8
+ gem "sqlite3", "~> 1.3.6"
7
9
 
8
10
  gemspec path: "../"
@@ -2,7 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.0"
6
- gem "mysql2", ">= 0.3.18", "< 0.5"
5
+ gem "activerecord", "~> 5.0.7"
6
+ gem "mysql2", ">= 0.3.18", "< 0.6.0"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.3.6"
7
9
 
8
10
  gemspec path: "../"
@@ -2,7 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1.0"
6
- gem "mysql2", ">= 0.3.18", "< 0.5"
5
+ gem "activerecord", "~> 5.1.7"
6
+ gem "mysql2", ">= 0.3.18", "< 0.6.0"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
7
9
 
8
10
  gemspec path: "../"
@@ -2,7 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.2.0.beta2"
6
- gem "mysql2", ">= 0.3.18", "< 0.5", "!= 0.4.3"
5
+ gem "activerecord", "~> 5.2.3"
6
+ gem "mysql2", ">= 0.4.4", "< 0.6.0"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
7
9
 
8
10
  gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.0.0.beta3"
6
+ gem "mysql2", ">= 0.4.4"
7
+ gem "pg", ">= 0.18", "< 2.0"
8
+ gem "sqlite3", "~> 1.4"
9
+
10
+ gemspec path: "../"
@@ -12,7 +12,7 @@ module Unread
12
12
 
13
13
  joins "LEFT JOIN #{ReadMark.quoted_table_name}
14
14
  ON #{ReadMark.quoted_table_name}.readable_type = '#{readable.class.readable_parent.name}'
15
- AND (#{ReadMark.quoted_table_name}.readable_id = #{readable.id} OR #{ReadMark.quoted_table_name}.readable_id IS NULL)
15
+ AND (#{ReadMark.quoted_table_name}.readable_id = #{quote_bound_value(readable.id)} OR #{ReadMark.quoted_table_name}.readable_id IS NULL)
16
16
  AND #{ReadMark.quoted_table_name}.reader_id = #{quoted_table_name}.#{quoted_primary_key}
17
17
  AND #{ReadMark.quoted_table_name}.reader_type = '#{connection.quote_string base_class.name}'
18
18
  AND #{ReadMark.quoted_table_name}.timestamp >= '#{connection.quoted_date readable.send(readable.class.readable_options[:on])}'"
@@ -31,8 +31,8 @@ module Unread
31
31
 
32
32
  join_read_marks(readable).select("#{quoted_table_name}.*,
33
33
  #{ReadMark.quoted_table_name}.id AS read_mark_id,
34
- #{quote_bound_value readable.class.name}#{postgresql_string_cast} AS read_mark_readable_type,
35
- #{readable.id} AS read_mark_readable_id")
34
+ #{quote_bound_value(readable.class.name)}#{postgresql_string_cast} AS read_mark_readable_type,
35
+ #{quote_bound_value(readable.id)} AS read_mark_readable_id")
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module Unread
2
- VERSION = '0.10.1'
2
+ VERSION = '0.11.0'
3
3
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "https://github.com/ledermann/unread"
13
13
  s.summary = %q{Manages read/unread status of ActiveRecord objects}
14
14
  s.description = %q{This gem creates a scope for unread objects and adds methods to mark objects as read }
15
- s.required_ruby_version = '>= 2.2'
15
+ s.required_ruby_version = '>= 2.4'
16
16
 
17
17
  s.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency 'timecop'
29
29
  s.add_development_dependency 'sqlite3'
30
30
  s.add_development_dependency 'mysql2'
31
- s.add_development_dependency 'pg', '< 1'
31
+ s.add_development_dependency 'pg'
32
32
  s.add_development_dependency 'rspec'
33
33
  s.add_development_dependency 'simplecov'
34
34
  s.add_development_dependency 'term-ansicolor'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2019-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: pg
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "<"
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '1'
103
+ version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "<"
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '1'
110
+ version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -201,6 +201,7 @@ files:
201
201
  - gemfiles/rails_5_0.gemfile
202
202
  - gemfiles/rails_5_1.gemfile
203
203
  - gemfiles/rails_5_2.gemfile
204
+ - gemfiles/rails_6_0.gemfile
204
205
  - lib/generators/unread/migration/migration_generator.rb
205
206
  - lib/generators/unread/migration/templates/migration.rb
206
207
  - lib/generators/unread/polymorphic_reader_migration/polymorphic_reader_migration_generator.rb
@@ -227,15 +228,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
228
  requirements:
228
229
  - - ">="
229
230
  - !ruby/object:Gem::Version
230
- version: '2.2'
231
+ version: '2.4'
231
232
  required_rubygems_version: !ruby/object:Gem::Requirement
232
233
  requirements:
233
234
  - - ">="
234
235
  - !ruby/object:Gem::Version
235
236
  version: '0'
236
237
  requirements: []
237
- rubyforge_project:
238
- rubygems_version: 2.7.6
238
+ rubygems_version: 3.0.6
239
239
  signing_key:
240
240
  specification_version: 4
241
241
  summary: Manages read/unread status of ActiveRecord objects