FIX: correct topics and posts count in import:ensure_consistency rake task (#30104)

After running the rake task the post and topics counts where way off. When investigating, I found this six-year-old #TODO. It was an easy fix.
This commit is contained in:
communiteq 2024-12-30 15:15:18 +01:00 committed by GitHub
parent bf35f7f860
commit bc3b38db19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -299,13 +299,11 @@ end
def update_user_stats def update_user_stats
log "Updating user stats..." log "Updating user stats..."
# TODO: topic_count is counting all topics you replied in as if you started the topic.
# TODO: post_count is counting first posts.
DB.exec <<-SQL DB.exec <<-SQL
WITH X AS ( WITH X AS (
SELECT p.user_id SELECT p.user_id
, COUNT(p.id) posts , COUNT(CASE WHEN p.post_number > 1 THEN p.id END) AS posts
, COUNT(DISTINCT p.topic_id) topics , COUNT(CASE WHEN p.post_number = 1 THEN t.id END) AS topics
, MIN(p.created_at) min_created_at , MIN(p.created_at) min_created_at
, COALESCE(COUNT(DISTINCT DATE(p.created_at)), 0) days , COALESCE(COUNT(DISTINCT DATE(p.created_at)), 0) days
FROM posts p FROM posts p