mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 00:35:45 +08:00
Import user visits from user_log table
This commit is contained in:
parent
e8e8d540d3
commit
ac44374a59
@ -131,7 +131,8 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
duplicate_emails = mysql_query("SELECT email FROM users GROUP BY email HAVING COUNT(email) > 1").map { |e| [e["email"], 0] }.to_h
|
||||
|
||||
create_users(users, total: user_count, offset: offset) do |user|
|
||||
profile = profiles.select { |p| p["user_id"] == user["id"] }
|
||||
user_id = user["id"]
|
||||
profile = profiles.select { |p| p["user_id"] == user_id }
|
||||
result = profile.select { |p| p["param"] == "profile.location" }
|
||||
location = result.count > 0 ? result.first["nvalue"] : nil
|
||||
username = user["login_canon"]
|
||||
@ -144,7 +145,7 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
end
|
||||
|
||||
{
|
||||
id: user["id"],
|
||||
id: user_id,
|
||||
name: user["nlogin"],
|
||||
username: username,
|
||||
email: email,
|
||||
@ -157,6 +158,20 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
post_create_action: proc do |u|
|
||||
@old_username_to_new_usernames[user["login_canon"]] = u.username
|
||||
|
||||
# import user visits
|
||||
visits = mysql_query <<-SQL
|
||||
SELECT login_time
|
||||
FROM user_log
|
||||
WHERE user_id = #{user_id}
|
||||
SQL
|
||||
|
||||
if visits.count > 0
|
||||
visits.each do |visit|
|
||||
date = unix_time(visit["login_time"]).to_date
|
||||
u.update_visit_record!(date)
|
||||
end
|
||||
end
|
||||
|
||||
# import user avatar
|
||||
sso_id = u.custom_fields["sso_id"]
|
||||
if sso_id.present?
|
||||
|
Loading…
x
Reference in New Issue
Block a user