Auxiliary script changes for testing in Prod 20240829
This commit is contained in:
parent
07206daecb
commit
1856f822ba
BIN
.gossamer_forums.rb.swp
Normal file
BIN
.gossamer_forums.rb.swp
Normal file
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
# Load the Discourse environment
|
||||
require File.expand_path("../../../config/environment", __FILE__)
|
||||
require File.expand_path("../../../../config/environment", __FILE__)
|
||||
|
||||
# require_relative '/var/www/discourse/config/environment'
|
||||
|
||||
@ -26,3 +26,15 @@ end
|
||||
username = 'davidpaulyoung'
|
||||
|
||||
query_md5_password_custom_field(username)
|
||||
|
||||
username = 'Slowman'
|
||||
|
||||
query_md5_password_custom_field(username)
|
||||
|
||||
username = 'GT'
|
||||
|
||||
query_md5_password_custom_field(username)
|
||||
|
||||
username = 'Chimpking'
|
||||
|
||||
query_md5_password_custom_field(username)
|
||||
|
@ -75,6 +75,34 @@ class GossamerForumsCleaner
|
||||
end
|
||||
end
|
||||
|
||||
def cleanup_topics_with_invalid_posts_count
|
||||
puts "Cleaning up topics with invalid posts_count..."
|
||||
|
||||
# Find all topics that were imported
|
||||
TopicCustomField.where(name: 'original_gossamer_id').each do |field|
|
||||
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}"
|
||||
|
||||
# Destroy all posts in the topic
|
||||
# topic.posts.each do |post|
|
||||
# puts "Deleting post #{post.id} in topic #{topic.id}"
|
||||
# post.destroy
|
||||
# end
|
||||
#
|
||||
# # Destroy the topic itself
|
||||
# topic.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def cleanup_posts
|
||||
puts "Cleaning up imported posts..."
|
||||
# Find all posts that were imported and delete them
|
||||
@ -131,7 +159,8 @@ class GossamerForumsCleaner
|
||||
puts "Cleanup beginning!"
|
||||
# cleanup_messages
|
||||
# cleanup_topics
|
||||
cleanup_topics_former_user
|
||||
# cleanup_topics_former_user
|
||||
cleanup_topics_with_invalid_posts_count
|
||||
# cleanup_posts_parallel
|
||||
# cleanup_categories
|
||||
# cleanup_users
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Load the Discourse environment
|
||||
require File.expand_path("../../../config/environment", __FILE__)
|
||||
require File.expand_path("../../../../config/environment", __FILE__)
|
||||
|
||||
# require_relative '/var/www/discourse/config/environment'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user