Auxiliary script changes for testing in Prod 20240829

This commit is contained in:
David Sainty 2024-08-29 20:52:55 +10:00
parent 174e341973
commit e6f7d313ac

View File

@ -78,17 +78,8 @@ class GossamerForumsCleaner
def cleanup_topics_with_invalid_posts_count def cleanup_topics_with_invalid_posts_count
puts "Cleaning up topics with invalid posts_count..." puts "Cleaning up topics with invalid posts_count..."
# Find all topics that were imported # Iterate through all topics
TopicCustomField.where(name: 'original_gossamer_id').each do |field| Topic.where("posts_count IS NULL OR posts_count = -1").find_each do |topic|
topic = Topic.find_by(id: field.topic_id)
next unless topic
# Check if the posts_count is nil or -1
if topic.posts_count.nil? || topic.posts_count == -1
# first_post = topic.posts.order(:created_at).first
# user_name = first_post&.user&.username || 'Unknown'
puts "Identified topic for deletion: Title: #{topic.title} Topic ID: #{topic.id}" puts "Identified topic for deletion: Title: #{topic.title} Topic ID: #{topic.id}"
# Destroy all posts in the topic # Destroy all posts in the topic
@ -101,7 +92,6 @@ class GossamerForumsCleaner
# topic.destroy # topic.destroy
end end
end end
end
def cleanup_posts def cleanup_posts
puts "Cleaning up imported posts..." puts "Cleaning up imported posts..."