v0.60 Final tweak for topic and user count updating for last public posts
This commit is contained in:
parent
a39e435ffe
commit
bd119a3000
@ -1,7 +1,7 @@
|
||||
# Federated Computer, Inc.
|
||||
# David Sainty <saint@federated.computer> 2024 A.D.
|
||||
# Gossamer Threads to Discourse -- Migration-Import Script
|
||||
# v0.59 Final topic-post import run -- add logic for appending counts since we are adding to a live Discourse host now
|
||||
# v0.60 Final tweak for topic and user count updating for last public posts
|
||||
|
||||
require 'mysql2'
|
||||
require 'open-uri'
|
||||
@ -1816,7 +1816,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
# last_post_user_id: topic_last_post_user[topic_id]
|
||||
# )
|
||||
# end
|
||||
@db.execute("SELECT * FROM topic_last_post_time_final").each do |row|
|
||||
@db.execute("SELECT * FROM topic_last_post_time").each do |row|
|
||||
topic_id, last_post_time = row
|
||||
|
||||
begin
|
||||
@ -1843,15 +1843,16 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
|
||||
@db.execute("SELECT * FROM topic_last_post_time_final").each do |row|
|
||||
topic_id, last_post_time = row
|
||||
puts "update_topic_stats_final topic_id #{topic_id}"
|
||||
|
||||
begin
|
||||
topic = Topic.find(topic_id)
|
||||
|
||||
# Calculate the new values based on the given conditions
|
||||
new_updated_at = [Time.at(last_post_time), topic.updated_at].max
|
||||
new_updated_at = Time.at(last_post_time)
|
||||
new_posts_count = topic.posts_count + fetch_db_topic_post_count(topic_id).to_i
|
||||
new_last_posted_at = [Time.at(last_post_time), topic.last_posted_at].max
|
||||
new_bumped_at = [Time.at(last_post_time), topic.bumped_at].max
|
||||
new_last_posted_at = Time.at(last_post_time)
|
||||
new_bumped_at = Time.at(last_post_time)
|
||||
new_last_post_user_id = fetch_db_topic_last_post_user(topic_id).to_i
|
||||
|
||||
# Update the topic with the calculated values
|
||||
@ -2159,7 +2160,7 @@ class GossamerForumsImporter < ImportScripts::Base
|
||||
|
||||
### import_categories
|
||||
|
||||
import_topics_and_posts
|
||||
## import_topics_and_posts
|
||||
# threaded_topic_import
|
||||
|
||||
#### update_topic_stats
|
||||
|
Loading…
Reference in New Issue
Block a user