DEV: set digest_attempted_at during migrations (#11369)

This commit is contained in:
Régis Hanol 2020-12-14 00:58:14 +01:00 committed by GitHub
parent b913afe5bb
commit a85d5edbf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -285,7 +285,7 @@ class BulkImport::Base
user_id topics_entered time_read days_visited posts_read_count user_id topics_entered time_read days_visited posts_read_count
likes_given likes_received new_since read_faq likes_given likes_received new_since read_faq
first_post_created_at post_count topic_count bounce_score first_post_created_at post_count topic_count bounce_score
reset_bounce_score_after reset_bounce_score_after digest_attempted_at
} }
USER_PROFILE_COLUMNS ||= %i{ USER_PROFILE_COLUMNS ||= %i{
@ -435,7 +435,6 @@ class BulkImport::Base
user_email[:updated_at] ||= user_email[:created_at] user_email[:updated_at] ||= user_email[:created_at]
user_email[:email] ||= random_email user_email[:email] ||= random_email
user_email[:email].downcase! user_email[:email].downcase!
user_email user_email
end end
@ -451,11 +450,12 @@ class BulkImport::Base
user_stat[:post_count] ||= 0 user_stat[:post_count] ||= 0
user_stat[:topic_count] ||= 0 user_stat[:topic_count] ||= 0
user_stat[:bounce_score] ||= 0 user_stat[:bounce_score] ||= 0
user_stat[:digest_attempted_at] ||= NOW
user_stat user_stat
end end
def process_user_profile(user_profile) def process_user_profile(user_profile)
user_profile[:bio_raw] = (user_profile[:bio_raw].presence || "").scrub.strip.presence user_profile[:bio_raw] = (user_profile[:bio_raw].presence || "").scrub.strip.presence
user_profile[:bio_cooked] = pre_cook(user_profile[:bio_raw]) if user_profile[:bio_raw].present? user_profile[:bio_cooked] = pre_cook(user_profile[:bio_raw]) if user_profile[:bio_raw].present?
user_profile[:views] ||= 0 user_profile[:views] ||= 0
user_profile user_profile
@ -494,7 +494,7 @@ class BulkImport::Base
topic[:closed] ||= false topic[:closed] ||= false
topic[:views] ||= 0 topic[:views] ||= 0
topic[:created_at] ||= NOW topic[:created_at] ||= NOW
topic[:bumped_at] ||= topic[:created_at] topic[:bumped_at] ||= topic[:created_at]
topic[:updated_at] ||= topic[:created_at] topic[:updated_at] ||= topic[:created_at]
topic topic
end end

View File

@ -737,6 +737,10 @@ class ImportScripts::Base
WHERE u1.user_id = user_stats.user_id WHERE u1.user_id = user_stats.user_id
AND user_stats.topic_count <> sub.topic_count AND user_stats.topic_count <> sub.topic_count
SQL SQL
puts "", "Updating user digest_attempted_at..."
DB.exec("UPDATE user_stats SET digest_attempted_at = now() WHERE digest_attempted_at IS NULL")
end end
# scripts that are able to import last_seen_at from the source data should override this method # scripts that are able to import last_seen_at from the source data should override this method