FIX: Restrict duplicate timings from being moved with posts (#30311)

This commit is contained in:
Gary Pendergast 2024-12-17 16:47:34 +11:00 committed by GitHub
parent 4437aced91
commit c2f7da3298
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -478,7 +478,9 @@ class PostMover
def copy_shifted_post_timings_from_temp def copy_shifted_post_timings_from_temp
DB.exec <<~SQL DB.exec <<~SQL
INSERT INTO post_timings (topic_id, user_id, post_number, msecs) INSERT INTO post_timings (topic_id, user_id, post_number, msecs)
SELECT DISTINCT topic_id, user_id, post_number, msecs FROM temp_post_timings SELECT DISTINCT ON (topic_id, post_number, user_id) topic_id, user_id, post_number, msecs
FROM temp_post_timings
ORDER BY topic_id, post_number, user_id, msecs DESC
ON CONFLICT (topic_id, post_number, user_id) DO UPDATE ON CONFLICT (topic_id, post_number, user_id) DO UPDATE
SET msecs = GREATEST(post_timings.msecs, excluded.msecs) SET msecs = GREATEST(post_timings.msecs, excluded.msecs)
SQL SQL