From bd119a3000b978c8195f42d5564f85d79b790f73 Mon Sep 17 00:00:00 2001 From: saint Date: Mon, 2 Sep 2024 17:03:50 +1000 Subject: [PATCH] v0.60 Final tweak for topic and user count updating for last public posts --- gossamer_forums.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gossamer_forums.rb b/gossamer_forums.rb index 8356f70..ed7226b 100644 --- a/gossamer_forums.rb +++ b/gossamer_forums.rb @@ -1,7 +1,7 @@ # Federated Computer, Inc. # David Sainty 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