From 7351882171b835421bfebb42528807b00ff4c054 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Thu, 17 Jun 2021 12:37:29 -0500 Subject: [PATCH] Revert "Use `add_directory_column` API to add solutions count to user directory (#137)" (#139) This reverts commit 58c594fdda0a8c35a6f52079e1d8909619f6e2df. --- config/locales/client.en.yml | 1 - ...171830_add_solutions_to_directory_items.rb | 7 ------- plugin.rb | 20 ------------------- 3 files changed, 28 deletions(-) delete mode 100644 db/migrate/20210609171830_add_solutions_to_directory_items.rb diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7cffd18..f66942c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -4,7 +4,6 @@ en: alt: solved: accepted_notification: "accepted" - solutions: "Solutions" solved: title: "Solved" diff --git a/db/migrate/20210609171830_add_solutions_to_directory_items.rb b/db/migrate/20210609171830_add_solutions_to_directory_items.rb deleted file mode 100644 index eccccf8..0000000 --- a/db/migrate/20210609171830_add_solutions_to_directory_items.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class AddSolutionsToDirectoryItems < ActiveRecord::Migration[6.1] - def change - add_column :directory_items, :solutions, :integer, default: 0 - end -end diff --git a/plugin.rb b/plugin.rb index 88dd7a0..01f5e14 100644 --- a/plugin.rb +++ b/plugin.rb @@ -613,26 +613,6 @@ SQL options[:refresh_stream] = true if old_category_allows != new_category_allows end - query = " - WITH x AS (SELECT - u.id user_id, - COUNT(DISTINCT ua.id) AS solutions - FROM users AS u - INNER JOIN user_actions AS ua ON ua.user_id = u.id AND ua.action_type = #{UserAction::SOLVED} AND COALESCE(ua.created_at, :since) > :since - WHERE u.active - AND u.silenced_till IS NULL - AND u.id > 0 - GROUP BY u.id - ) - UPDATE directory_items di SET - solutions = x.solutions - FROM x - WHERE x.user_id = di.user_id - AND di.period_type = :period_type - AND di.solutions <> x.solutions - " - add_directory_column("solutions", query: query) - add_to_class(:composer_messages_finder, :check_topic_is_solved) do return if !SiteSetting.solved_enabled || SiteSetting.disable_solved_education_message return if !replying? || @topic.blank? || @topic.private_message?