thredded 0.16.5 → 0.16.6

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: 1addbc714333793d7418de6373463dbd991352f8c4f9dc3382f88f4f38fb6d02
4
- data.tar.gz: 86115c68b177a7290e6587e4b12f541cb298759956b0f9de001d6b7a699ed3c7
3
+ metadata.gz: 903f97feaa1caa7429abcaddaeb75baa31065081cdef9beb1b080b9231961be0
4
+ data.tar.gz: 7b9bf56abfddf2da79c002bf623c6d5c8e3fdd124a45bfb9e684b7ea1f88c2e3
5
5
  SHA512:
6
- metadata.gz: eaf9db260983b5ac06e476ba642a44a162ae0c521a4fa87d5d79d346fc2c06a73d69052c9a25ee8658936d115cd57044627f9fdcf862577ade2e7dd029ede6a0
7
- data.tar.gz: 50948e3ebd7f3570fc5517fbb41656ca40bc4acd435753c7f268f45fd0a017dc9f7238a74292a2c651292a71130c7bbb2e78ba3e4306dfd81f5d5d2471333075
6
+ metadata.gz: e0d77ddf04ae512ac702cdb8ce062649800095e51e3ed92d4a5bc1f9d0aa042abde28abea3df2a5c9f87f73171e3715bb75c6ecb8265fa1587a7b0672c9fb46e
7
+ data.tar.gz: 5013b97d8f96962a6194cfd1377b3b04787f1400d6ec1481737f9fd263c6c9aafcb5e72776ed82df020d3f2a22c6ca61d841f26fafa74337f1604254b6b3f1e7
data/README.md CHANGED
@@ -95,7 +95,7 @@ Then, see the rest of this Readme for more information about using and customizi
95
95
  Add the gem to your Gemfile:
96
96
 
97
97
  ```ruby
98
- gem 'thredded', '~> 0.16.5'
98
+ gem 'thredded', '~> 0.16.6'
99
99
  ```
100
100
 
101
101
  Add the Thredded [initializer] to your parent app by running the install generator.
@@ -8,11 +8,9 @@ module Thredded
8
8
  def pending
9
9
  @posts = Thredded::PostsPageView.new(
10
10
  thredded_current_user,
11
- moderatable_posts
12
- .pending_moderation
13
- .order_oldest_first
14
- .preload(:user, :postable)
11
+ preload_posts_for_moderation(moderatable_posts.pending_moderation).order_newest_first
15
12
  .send(Kaminari.config.page_method_name, current_page)
13
+ .preload_first_topic_post
16
14
  )
17
15
  maybe_set_last_moderated_record_flash
18
16
  end
@@ -26,10 +24,9 @@ module Thredded
26
24
  def activity
27
25
  @posts = Thredded::PostsPageView.new(
28
26
  thredded_current_user,
29
- moderatable_posts
30
- .order_newest_first
31
- .preload(:user, :postable, :messageboard)
27
+ preload_posts_for_moderation(moderatable_posts).order_oldest_first
32
28
  .send(Kaminari.config.page_method_name, current_page)
29
+ .preload_first_topic_post
33
30
  )
34
31
  maybe_set_last_moderated_record_flash
35
32
  end
@@ -114,5 +111,9 @@ module Thredded
114
111
  def current_page
115
112
  (params[:page] || 1).to_i
116
113
  end
114
+
115
+ def preload_posts_for_moderation(posts)
116
+ posts.includes(:user, :messageboard, :postable)
117
+ end
117
118
  end
118
119
  end
@@ -18,6 +18,18 @@ module Thredded
18
18
  scope :order_oldest_first, -> { order(created_at: :asc, id: :asc) }
19
19
  scope :order_newest_first, -> { order(created_at: :desc, id: :desc) }
20
20
 
21
+ scope :preload_first_topic_post, -> {
22
+ posts_table_name = quoted_table_name
23
+ ActiveRecord::Associations::Preloader.new.preload(
24
+ map(&:postable), :first_post,
25
+ Thredded::Post.where(<<~SQL.delete("\n"))
26
+ #{posts_table_name}.created_at = (
27
+ SELECT MAX(p2.created_at) from #{posts_table_name} p2 WHERE p2.postable_id = #{posts_table_name}.postable_id)
28
+ SQL
29
+ )
30
+ self
31
+ }
32
+
21
33
  before_validation :ensure_user_detail, on: :create
22
34
 
23
35
  after_commit :update_unread_posts_count, on: %i[create destroy]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- VERSION = '0.16.5'
4
+ VERSION = '0.16.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.5
4
+ version: 0.16.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Oliveira
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-27 00:00:00.000000000 Z
12
+ date: 2019-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_record_union
@@ -331,14 +331,14 @@ dependencies:
331
331
  requirements:
332
332
  - - ">="
333
333
  - !ruby/object:Gem::Version
334
- version: '0'
334
+ version: 5.0.1
335
335
  type: :development
336
336
  prerelease: false
337
337
  version_requirements: !ruby/object:Gem::Requirement
338
338
  requirements:
339
339
  - - ">="
340
340
  - !ruby/object:Gem::Version
341
- version: '0'
341
+ version: 5.0.1
342
342
  - !ruby/object:Gem::Dependency
343
343
  name: faker
344
344
  requirement: !ruby/object:Gem::Requirement