v0.27.2 Improvement for user stat handling
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
# gossamer threads migration-import code
 | 
					# gossamer threads migration-import code
 | 
				
			||||||
# v0.27.1
 | 
					# v0.27.2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require 'mysql2'
 | 
					require 'mysql2'
 | 
				
			||||||
require 'open-uri'
 | 
					require 'open-uri'
 | 
				
			||||||
@@ -1084,7 +1084,7 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
    puts "Importing topics and posts with attachments... Done."
 | 
					    puts "Importing topics and posts with attachments... Done."
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def update_topic_and_user_stats
 | 
					  def update_topic_stats
 | 
				
			||||||
    # Update topics with the correct last post time, post count, and last post user
 | 
					    # Update topics with the correct last post time, post count, and last post user
 | 
				
			||||||
    puts "Update topics with the correct last post time, post count, and last post user"
 | 
					    puts "Update topics with the correct last post time, post count, and last post user"
 | 
				
			||||||
#    topic_last_post_time.each do |topic_id, last_post_time|
 | 
					#    topic_last_post_time.each do |topic_id, last_post_time|
 | 
				
			||||||
@@ -1110,7 +1110,9 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
        last_post_user_id: fetch_db_topic_last_post_user(topic_id).to_i
 | 
					        last_post_user_id: fetch_db_topic_last_post_user(topic_id).to_i
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def update_user_stats
 | 
				
			||||||
    # Update user profiles with the number of topics and posts created
 | 
					    # Update user profiles with the number of topics and posts created
 | 
				
			||||||
    puts "Update user profiles with the number of topics and posts created"
 | 
					    puts "Update user profiles with the number of topics and posts created"
 | 
				
			||||||
#    user_topic_count.each do |user_id, count|
 | 
					#    user_topic_count.each do |user_id, count|
 | 
				
			||||||
@@ -1123,14 +1125,18 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
#    end
 | 
					#    end
 | 
				
			||||||
    @db.execute("SELECT * FROM user_topic_count").each do |row|
 | 
					    @db.execute("SELECT * FROM user_topic_count").each do |row|
 | 
				
			||||||
      user_id, count = row
 | 
					      user_id, count = row
 | 
				
			||||||
      user = User.find(user_id)
 | 
					#      user = User.find(user_id)
 | 
				
			||||||
      user.update!(topic_count: count)
 | 
					#      user.update!(topic_count: count)
 | 
				
			||||||
 | 
					      user_stat = UserStat.find_or_initialize_by(user_id: user_id)
 | 
				
			||||||
 | 
					      user_stat.update_columns(topic_count: count)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
    @db.execute("SELECT * FROM user_post_count").each do |row|
 | 
					    @db.execute("SELECT * FROM user_post_count").each do |row|
 | 
				
			||||||
      user_id, count = row
 | 
					      user_id, count = row
 | 
				
			||||||
      user = User.find(user_id)
 | 
					#      user = User.find(user_id)
 | 
				
			||||||
      user.update!(post_count: count)
 | 
					#      user.update!(post_count: count)
 | 
				
			||||||
 | 
					      user_stat = UserStat.find_or_initialize_by(user_id: user_id)
 | 
				
			||||||
 | 
					      user_stat.update_columns(post_count: count)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1213,7 +1219,8 @@ class GossamerForumsImporter < ImportScripts::Base
 | 
				
			|||||||
#    import_categories
 | 
					#    import_categories
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    import_topics_and_posts_with_attachments
 | 
					#    import_topics_and_posts_with_attachments
 | 
				
			||||||
    update_topic_and_user_stats
 | 
					#    update_topic_stats
 | 
				
			||||||
 | 
					    update_user_stats
 | 
				
			||||||
    export_url_mapping_to_csv("gossamer-migration-url-mapping#{timestamp}")
 | 
					    export_url_mapping_to_csv("gossamer-migration-url-mapping#{timestamp}")
 | 
				
			||||||
    create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf")
 | 
					    create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user