Add label import
This commit is contained in:
parent
a00fda47a5
commit
48ceb1d872
1 changed files with 20 additions and 0 deletions
|
@ -8,6 +8,8 @@ class MigrateToCloud::ImportToCloud
|
|||
import_users_to_account
|
||||
when 'contact'
|
||||
import_contacts_to_account
|
||||
when 'label'
|
||||
import_labels_to_account
|
||||
when 'conversation'
|
||||
import_conversations_to_account
|
||||
when 'message'
|
||||
|
@ -81,6 +83,24 @@ class MigrateToCloud::ImportToCloud
|
|||
account.contacts.insert_all(data)
|
||||
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
|
||||
filename = 'export/conversations.csv'
|
||||
iterator = 1
|
||||
|
|
Loading…
Reference in a new issue