From 5f39a8b4b2b1f38745f601c8b5fc6de585efa441 Mon Sep 17 00:00:00 2001 From: evazion Date: Mon, 13 Nov 2017 21:45:12 -0600 Subject: [PATCH] Fix #3365: Incorrect tag category counts. `Hash[array]` didn't work because Hash needed to be called as `Hash[*array]`. Or, more simply, `array.to_h`. --- app/models/post.rb | 2 +- app/models/tag.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 2f052a8b1..bf0f2a406 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -626,7 +626,7 @@ class Post < ApplicationRecord def set_tag_counts self.tag_count = 0 - TagCategory.categories {|x| set_tag_count(x,0)} + TagCategory.categories.each {|x| set_tag_count(x,0)} categories = Tag.categories_for(tag_array, :disable_caching => true) categories.each_value do |category| self.tag_count += 1 diff --git a/app/models/tag.rb b/app/models/tag.rb index 6980dafdb..c48ef4606 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -142,7 +142,7 @@ class Tag < ApplicationRecord Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post| post.reload post.set_tag_counts - args = Hash[TagCategory.categories {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}].update(:tag_count => post.tag_count) + args = TagCategory.categories.map {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}.to_h.update(:tag_count => post.tag_count) Post.where(:id => post.id).update_all(args) end end