Class: XmlImport

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/xml_import.rb

Overview

Schema Information

Table name: xml_imports

id                 :integer          not null, primary key
xml_import_type_id :integer          default(1)
updated_count      :integer          default(0)
created_count      :integer          default(0)
created_at         :datetime
updated_at         :datetime

Instance Method Summary collapse

Instance Method Details

#kindObject



28
29
30
# File 'app/models/xml_import.rb', line 28

def kind
  xml_import_type.title
end

#startObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/models/xml_import.rb', line 32

def start
  path = (attachment_file || AttachmentFile.where(guid: fileupload_guid).first).try(:data).try(:path)
  return nil if path.nil?

  response = case xml_import_type.code
             when :post then TranslationCms::Import::Post.start(path, self)
             when :sample then TranslationCms::Import::Sample.start(path, self)
  end

  update_column :updated_count, response.updated_count.to_i
  update_column :created_count, response.created_count.to_i
end

#titleObject



24
25
26
# File 'app/models/xml_import.rb', line 24

def title
  I18n.l(created_at, format: :long)
end