Add label import

This commit is contained in:
Pranav Raj S 2022-06-04 19:33:04 +05:30
parent a00fda47a5
commit 48ceb1d872

View file

@ -8,6 +8,8 @@ class MigrateToCloud::ImportToCloud
import_users_to_account import_users_to_account
when 'contact' when 'contact'
import_contacts_to_account import_contacts_to_account
when 'label'
import_labels_to_account
when 'conversation' when 'conversation'
import_conversations_to_account import_conversations_to_account
when 'message' when 'message'
@ -81,6 +83,24 @@ class MigrateToCloud::ImportToCloud
account.contacts.insert_all(data) account.contacts.insert_all(data)
end end
def import_labels_to_account
filename = 'export/labels.csv'
data = []
CSV.foreach(filename, headers: true) do |row|
label = row.to_hash
new_label = {}
new_label['title'] = label['title']
new_label['description'] = label['description']
new_label['color'] = label['color']
new_label['show_on_sidebar'] = label['show_on_sidebar']
new_label['created_at'] = label['created_at']
new_label['updated_at'] = label['updated_at']
data.push(new_label)
end
log_to_console('INSERT_LABEL', "")
account.labels.insert_all(data)
end
def import_conversations_to_account def import_conversations_to_account
filename = 'export/conversations.csv' filename = 'export/conversations.csv'
iterator = 1 iterator = 1