From 4849ac0e490d3b03a5d37c98c05e863e85b41efd Mon Sep 17 00:00:00 2001 From: lanzhiheng Date: Wed, 16 Jan 2019 12:44:08 +0800 Subject: [PATCH] fix n plus one issue and remove some useless code. --- app/models/refinery/blog/post.rb | 6 +----- refinerycms-blog.gemspec | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index 1ae44ba1..1817e95e 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -51,10 +51,6 @@ def validating_source_urls? verify: [:resolve_redirects] } - class Translation - is_seo_meta - end - # Override this to disable required authors def author_required? !Refinery::Blog.user_class.nil? @@ -104,7 +100,7 @@ def with_globalize(conditions = {}) end end # A join implies readonly which we don't really want. - where(conditions).joins(:translations).where(globalized_conditions) + where(conditions).includes(:translations).where(globalized_conditions) .readonly(false) end diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec index 177f2e8c..18009fb7 100644 --- a/refinerycms-blog.gemspec +++ b/refinerycms-blog.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_dependency 'seo_meta', ['>=3.0.0', '~>3.0'] s.add_dependency 'rails_autolink', '~> 1.1.3' s.add_dependency 'friendly_id', ['< 5.3', '>= 5.1.0'] - s.add_dependency 'globalize', '~> 5.1.0' + s.add_dependency 'globalize', '~> 5.2.0' s.add_dependency 'activemodel-serializers-xml', '~> 1.0', '>= 1.0.1' s.add_dependency 'responders', '~> 2.0' end