mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
FEATURE: Import script for AnswerBase
Improves the generic database used by some import scripts: * Adds additional columns for users * Adds support for attachments * Allows setting the data type for keys (numeric or string) to ensure correct sorting
This commit is contained in:
parent
ff26b4ed9b
commit
c36c9c2ee5
5 changed files with 471 additions and 40 deletions
|
@ -82,19 +82,7 @@ class ImportScripts::Zendesk < ImportScripts::Base
|
|||
)
|
||||
end
|
||||
|
||||
@db.execute_sql(<<~SQL)
|
||||
DELETE FROM user
|
||||
WHERE NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM topic
|
||||
WHERE topic.user_id = user.id
|
||||
) AND NOT EXISTS(
|
||||
SELECT 1
|
||||
FROM post
|
||||
WHERE post.user_id = user.id
|
||||
)
|
||||
SQL
|
||||
|
||||
@db.delete_unused_users
|
||||
@db.sort_posts_by_created_at
|
||||
end
|
||||
|
||||
|
@ -188,7 +176,7 @@ class ImportScripts::Zendesk < ImportScripts::Base
|
|||
last_row_id = 0
|
||||
|
||||
batches do |offset|
|
||||
rows, last_row_id = @db.fetch_posts(last_row_id)
|
||||
rows, last_row_id = @db.fetch_sorted_posts(last_row_id)
|
||||
break if rows.empty?
|
||||
|
||||
next if all_records_exist?(:posts, rows.map { |row| row['id'] })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue