v0.27.2 Improvement for user stat handling
This commit is contained in:
parent
2bcd88a40d
commit
e052d0c939
@ -1,5 +1,5 @@
|
||||
# gossamer threads migration-import code
|
||||
# v0.27.1
|
||||
# v0.27.2
|
||||
|
||||
require 'mysql2'
|
||||
require 'open-uri'
|
||||
@ -1084,7 +1084,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
puts "Importing topics and posts with attachments... Done."
|
||||
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
|
||||
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|
|
||||
@ -1110,7 +1110,9 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
last_post_user_id: fetch_db_topic_last_post_user(topic_id).to_i
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def update_user_stats
|
||||
# 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|
|
||||
@ -1123,14 +1125,18 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
# end
|
||||
@db.execute("SELECT * FROM user_topic_count").each do |row|
|
||||
user_id, count = row
|
||||
user = User.find(user_id)
|
||||
user.update!(topic_count: count)
|
||||
# user = User.find(user_id)
|
||||
# user.update!(topic_count: count)
|
||||
user_stat = UserStat.find_or_initialize_by(user_id: user_id)
|
||||
user_stat.update_columns(topic_count: count)
|
||||
end
|
||||
|
||||
@db.execute("SELECT * FROM user_post_count").each do |row|
|
||||
user_id, count = row
|
||||
user = User.find(user_id)
|
||||
user.update!(post_count: count)
|
||||
# user = User.find(user_id)
|
||||
# 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
|
||||
|
||||
@ -1213,7 +1219,8 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
# import_categories
|
||||
|
||||
# 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}")
|
||||
create_nginx_rewrite_rules("gossamer-redirects#{timestamp}.conf")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user