thredded 0.16.14 → 0.16.15

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b96a82c0482d773cd074fdd77a4e67a408ba43e2e079bbbd2a4eefeb55085f37
4
- data.tar.gz: 6949b12a03a39430340dbd8870cb6e5cc4dcddc583e093de576e2a3621becdb4
3
+ metadata.gz: ac00c63103252bbf9bff35aa057a6630605ad897368010665476b8b4d2abfc3a
4
+ data.tar.gz: cf7c0937115c8967c8fed0ba5789e4445db0a9e8b098a3109563b63be3883059
5
5
  SHA512:
6
- metadata.gz: 4403418748bbb9b7bdcf5a503908fb526d60ff0f6100d11be98d64f625da8e9479c2be127adb2b88435686371d58cb75c39d1e4c73789e5e8297eabf9d01198d
7
- data.tar.gz: 154ddbcd92f7e8f705bf4fe27bbc32f03fff0e3af7fdb81aca82143783dfd389eed1cbd516802356288af0c839cd3ddc61087209037c60bc521bee072939efa6
6
+ metadata.gz: cd1d9295ea54d35b3f6f1ac48f741b2766645c118b4519b717d5c4f87d926be12492ff2f4b76449088dfe2357b10e518b28442c76ac2998c19614ea2d3631603
7
+ data.tar.gz: 6d8892713aba82af3017146f0c4f5f8238af39842f4536640689915fa3833b68dc63023502c23e1311a63b6dd45aec0c02c14e4be3367fa6b67e3a471df70caf
data/README.md CHANGED
@@ -96,7 +96,7 @@ Then, see the rest of this Readme for more information about using and customizi
96
96
  Add the gem to your Gemfile:
97
97
 
98
98
  ```ruby
99
- gem 'thredded', '~> 0.16.14'
99
+ gem 'thredded', '~> 0.16.15'
100
100
  ```
101
101
 
102
102
  Add the Thredded [initializer] to your parent app by running the install generator.
@@ -25,7 +25,7 @@ module Thredded
25
25
  def inline_svg_once(filename, id:, **transform_params)
26
26
  return if @already_inlined_svg_ids&.include?(id)
27
27
  record_already_inlined_svg(filename, id)
28
- inline_svg(filename, id: id, **transform_params)
28
+ inline_svg_tag(filename, id: id, **transform_params)
29
29
  end
30
30
 
31
31
  private
@@ -27,10 +27,9 @@ module Thredded
27
27
  end
28
28
 
29
29
  def calculate_post_counts
30
+ relation = self.class.visible_posts_scope(user).where(postable_id: postable_id)
30
31
  unread_posts_count, read_posts_count =
31
- self.class.visible_posts_scope(user)
32
- .where(postable_id: postable_id)
33
- .pluck(*self.class.post_counts_arel(read_at))[0]
32
+ Thredded::ArelCompat.pluck(relation, *self.class.post_counts_arel(read_at))[0]
34
33
  { unread_posts_count: unread_posts_count || 0, read_posts_count: read_posts_count || 0 }
35
34
  end
36
35
 
@@ -89,9 +88,9 @@ module Thredded
89
88
  def calculate_post_counts
90
89
  states = arel_table
91
90
  posts = post_class.arel_table
92
- joins(states.join(posts).on(states[:postable_id].eq(posts[:postable_id])).join_sources)
91
+ relation = joins(states.join(posts).on(states[:postable_id].eq(posts[:postable_id])).join_sources)
93
92
  .group(states[:id])
94
- .pluck(states[:id], *post_counts_arel(states[:read_at], posts: posts))
93
+ Thredded::ArelCompat.pluck(relation, states[:id], *post_counts_arel(states[:read_at], posts: posts))
95
94
  end
96
95
  end
97
96
  end
@@ -139,9 +139,11 @@ module Thredded
139
139
  .and(read_states[:user_id].eq(user.id))
140
140
  .and(read_states[:unread_posts_count].eq(0))
141
141
 
142
- joins(:topics).merge(topics_scope).joins(
142
+ relation = joins(:topics).merge(topics_scope).joins(
143
143
  messageboards.outer_join(read_states).on(read_states_join_cond).join_sources
144
- ).group(messageboards[:id]).pluck(
144
+ ).group(messageboards[:id])
145
+ Thredded::ArelCompat.pluck(
146
+ relation,
145
147
  :id,
146
148
  Arel::Nodes::Subtraction.new(topics[:id].count, read_states[:id].count)
147
149
  ).to_h
@@ -27,6 +27,9 @@ module Thredded
27
27
  return if !overwrite_newer && state.read_at? && state.read_at >= post.created_at
28
28
  state.read_at = post.created_at
29
29
  state.update!(state.calculate_post_counts)
30
+ rescue ActiveRecord::RecordNotUnique
31
+ # The record has been created from another connection, retry to find it.
32
+ retry
30
33
  end
31
34
 
32
35
  # @param [Thredded.user_class] user
@@ -31,6 +31,9 @@ module Thredded
31
31
  state.messageboard_id = post.messageboard_id
32
32
  state.read_at = post.created_at
33
33
  state.update!(state.calculate_post_counts)
34
+ rescue ActiveRecord::RecordNotUnique
35
+ # The record has been created from another connection, retry to find it.
36
+ retry
34
37
  end
35
38
 
36
39
  # @param [Thredded.user_class] user
@@ -20,7 +20,7 @@
20
20
 
21
21
  <%- if actions_html.present? %>
22
22
  <div class='thredded--post--dropdown'>
23
- <%= inline_svg 'thredded/three-dot-menu.svg', class: 'thredded--post--dropdown--toggle' %>
23
+ <%= inline_svg_tag 'thredded/three-dot-menu.svg', class: 'thredded--post--dropdown--toggle' %>
24
24
  <div class='thredded--post--dropdown--actions'>
25
25
  <%= actions_html %>
26
26
  </div>
@@ -2,9 +2,9 @@
2
2
  <% current = current_page_moderation? %>
3
3
  <li class="thredded--user-navigation--item thredded--user-navigation--moderation<%= ' thredded--is-current' if current %>">
4
4
  <%= link_to current ? nav_back_path : pending_moderation_path, rel: 'nofollow' do %>
5
- <%= inline_svg 'thredded/moderation.svg',
6
- class: 'thredded--icon',
7
- title: t('thredded.nav.moderation') %>
5
+ <%= inline_svg_tag 'thredded/moderation.svg',
6
+ class: 'thredded--icon',
7
+ title: t('thredded.nav.moderation') %>
8
8
  <span class="thredded--nav-text"><%= t 'thredded.nav.moderation' %></span>
9
9
  <% if posts_pending_moderation_count > 0 %>
10
10
  <span class="thredded--user-navigation--moderation--pending-count"><%= posts_pending_moderation_count %></span>
@@ -1,7 +1,7 @@
1
1
  <% current = current_page_preferences? %>
2
2
  <li class="thredded--user-navigation--settings thredded--user-navigation--item<%= ' thredded--is-current' if current %>">
3
3
  <%= link_to current ? nav_back_path(messageboard) : edit_preferences_path(messageboard), rel: 'nofollow' do %>
4
- <%= inline_svg 'thredded/settings.svg', class: 'thredded--icon', title: t('thredded.nav.settings') %>
4
+ <%= inline_svg_tag 'thredded/settings.svg', class: 'thredded--icon', title: t('thredded.nav.settings') %>
5
5
  <span class="thredded--nav-text"><%= t('thredded.nav.settings') %></span>
6
6
  <% end %>
7
7
  </li>
@@ -1,9 +1,9 @@
1
1
  <% current = current_page_private_topics? %>
2
2
  <li class="thredded--user-navigation--item thredded--user-navigation--private-topics<%= ' thredded--is-current' if current %>">
3
3
  <%= link_to current ? nav_back_path : private_topics_path, rel: 'nofollow' do %>
4
- <%= inline_svg 'thredded/private-messages.svg',
5
- class: 'thredded--icon',
6
- title: t('thredded.nav.private_topics') %>
4
+ <%= inline_svg_tag 'thredded/private-messages.svg',
5
+ class: 'thredded--icon',
6
+ title: t('thredded.nav.private_topics') %>
7
7
  <span class="thredded--nav-text"><%= t('thredded.nav.private_topics') %></span>
8
8
  <% if unread_private_topics_count > 0 -%>
9
9
  <span class="thredded--user-navigation--private-topics--unread"><%= unread_private_topics_count %></span>
@@ -20,7 +20,7 @@
20
20
  </span>
21
21
  <%= button_to topic.unfollow_path, form: {class: 'thredded--topic-header--follow-info--unfollow'} do %>
22
22
  <%= t('thredded.topics.unfollow') %>
23
- <%= inline_svg 'thredded/follow.svg', class: 'thredded--topic-header--follow-icon' %>
23
+ <%= inline_svg_tag 'thredded/follow.svg', class: 'thredded--topic-header--follow-icon' %>
24
24
  <% end %>
25
25
  </div>
26
26
  <% else %>
@@ -4,28 +4,37 @@ unless Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 2 || Rails::VERSIO
4
4
  require 'thredded/rails_lt_5_2_arel_case_node.rb'
5
5
  end
6
6
 
7
- if Rails::VERSION::MAJOR == 4
8
- # Make `pluck` compatible with Arel.
9
- require 'active_record/relation'
10
- ActiveRecord::Relation.prepend(Module.new do
11
- def pluck(*column_names)
12
- super(*column_names.map do |n|
13
- if n.is_a?(Arel::Node)
14
- Arel.sql(n.to_sql)
15
- elsif n.is_a?(Arel::Attributes::Attribute)
16
- n.name
17
- else
18
- n
19
- end
20
- end)
21
- end
22
- end)
23
- end
24
-
25
7
  module Thredded
26
8
  module ArelCompat
27
9
  module_function
28
10
 
11
+ # On Rails >= 5, this method simply returns `relation.pluck(*columns)`.
12
+ #
13
+ # Rails 4 `pluck` does not support Arel nodes and attributes. This method does.
14
+ #
15
+ # This is an external method because monkey-patching `pluck` would
16
+ # have compatibility issues, see:
17
+ #
18
+ # https://github.com/thredded/thredded/issues/842
19
+ # https://blog.newrelic.com/engineering/ruby-agent-module-prepend-alias-method-chains/
20
+ if Rails::VERSION::MAJOR > 4
21
+ def pluck(relation, *columns)
22
+ relation.pluck(*columns)
23
+ end
24
+ else
25
+ def pluck(relation, *columns)
26
+ relation.pluck(*columns.map do |n|
27
+ if n.is_a?(Arel::Node)
28
+ Arel.sql(n.to_sql)
29
+ elsif n.is_a?(Arel::Attributes::Attribute)
30
+ n.name
31
+ else
32
+ n
33
+ end
34
+ end)
35
+ end
36
+ end
37
+
29
38
  # @param [#connection] engine
30
39
  # @param [Arel::Nodes::Node] a integer node
31
40
  # @param [Arel::Nodes::Node] b integer node
@@ -39,12 +39,10 @@ module Thredded
39
39
  # Regardless, always store the onebox in a file cache to enable offline development,
40
40
  # persistence between test runs, and to improve performance.
41
41
  attr_accessor :onebox_views_cache
42
- attr_accessor :onebox_data_cache
43
42
  end
44
43
 
45
44
  if Rails.env.development? || Rails.env.test?
46
45
  self.onebox_views_cache = ActiveSupport::Cache::FileStore.new('tmp/cache/onebox-views')
47
- self.onebox_data_cache = ActiveSupport::Cache::FileStore.new('tmp/cache/onebox-data')
48
46
  end
49
47
 
50
48
  def call
@@ -84,8 +82,7 @@ module Thredded
84
82
  end
85
83
 
86
84
  def onebox_options(_url)
87
- { cache: context[:onebox_data_cache] || self.class.onebox_data_cache || Rails.cache,
88
- sanitize_config: SANITIZE_CONFIG }
85
+ { sanitize_config: SANITIZE_CONFIG }
89
86
  end
90
87
 
91
88
  def onebox_views_cache
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thredded
4
- VERSION = '0.16.14'
4
+ VERSION = '0.16.15'
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.14
4
+ version: 0.16.15
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-10-21 00:00:00.000000000 Z
12
+ date: 2019-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_record_union
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 1.6.0
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: 1.6.0
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: kaminari
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +208,7 @@ dependencies:
208
208
  version: '1.8'
209
209
  - - ">="
210
210
  - !ruby/object:Gem::Version
211
- version: 1.8.48
211
+ version: 1.8.99
212
212
  type: :runtime
213
213
  prerelease: false
214
214
  version_requirements: !ruby/object:Gem::Requirement
@@ -218,7 +218,7 @@ dependencies:
218
218
  version: '1.8'
219
219
  - - ">="
220
220
  - !ruby/object:Gem::Version
221
- version: 1.8.48
221
+ version: 1.8.99
222
222
  - !ruby/object:Gem::Dependency
223
223
  name: rinku
224
224
  requirement: !ruby/object:Gem::Requirement
@@ -1037,7 +1037,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1037
1037
  - !ruby/object:Gem::Version
1038
1038
  version: '0'
1039
1039
  requirements: []
1040
- rubygems_version: 3.0.6
1040
+ rubygems_version: 3.0.3
1041
1041
  signing_key:
1042
1042
  specification_version: 4
1043
1043
  summary: The best Rails forums engine ever.