mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
a5fbb90df4
Currently when a user creates posts that are moderated (for whatever reason), a popup is displayed saying the post needs approval and the total number of the user’s pending posts. But then this piece of information is kind of lost and there is nowhere for the user to know what are their pending posts or how many there are. This patch solves this issue by adding a new “Pending” section to the user’s activity page when there are some pending posts to display. When there are none, then the “Pending” section isn’t displayed at all.
23 lines
563 B
Ruby
23 lines
563 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PopulatePendingPostsCountColumn < ActiveRecord::Migration[6.1]
|
|
def up
|
|
execute <<~SQL
|
|
WITH to_update AS (
|
|
SELECT COUNT(id) AS posts, created_by_id
|
|
FROM reviewables
|
|
WHERE type = 'ReviewableQueuedPost'
|
|
AND status = #{ReviewableQueuedPost.statuses[:pending]}
|
|
GROUP BY created_by_id
|
|
)
|
|
UPDATE user_stats
|
|
SET pending_posts_count = to_update.posts
|
|
FROM to_update
|
|
WHERE to_update.created_by_id = user_stats.user_id
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
end
|
|
end
|