Class: Ecm::Blog::ImportPostsService
- Inherits:
-
ApplicationService
- Object
- Rails::AddOns::Service::Base
- ApplicationService
- Ecm::Blog::ImportPostsService
- Defined in:
- app/services/ecm/blog/import_posts_service.rb
Overview
Example:
You selected joomla posts from your database like this:
SELECT joomla_content.title, joomla_content.fulltext, joomla_content.created, joomla_content.modified, joomla_users.email
FROM joomla_content, joomla_users
where created_by = joomla_users.id;
And exported the data into a csv file like this:
# tmp/old_posts.csv
title;fulltext;created;modified;email
"My first Post";"This is the body";"2013-02-12 14:22:23";"2013-02-12 21:58:54";john.doe@example.com
You can import this csv file from the rails console:
# rails console
Ecm::Blog::ImportPostsService.call({ filename: 'tmp/old_posts.csv', column_map: :joomla, body_source_format: :html }, autosave: true)
Defined Under Namespace
Classes: Result
Constant Summary collapse
- COLUMN_MAPS =
{ joomla: { title: :title, body: :fulltext, created_at: :created, updated_at: :modified, # published_at: ->(row) { Time.zone.now }, published_at: :created, creator_email: :email } }
- BODY_SOURCE_FORMATS =
[:markdown, :html]
Instance Attribute Summary collapse
-
#body_source_format ⇒ Object
Returns the value of attribute body_source_format.
-
#column_map ⇒ Object
Returns the value of attribute column_map.
-
#filename ⇒ Object
Returns the value of attribute filename.
Class Method Summary collapse
Instance Attribute Details
#body_source_format ⇒ Object
Returns the value of attribute body_source_format.
51 52 53 |
# File 'app/services/ecm/blog/import_posts_service.rb', line 51 def body_source_format @body_source_format end |
#column_map ⇒ Object
Returns the value of attribute column_map.
51 52 53 |
# File 'app/services/ecm/blog/import_posts_service.rb', line 51 def column_map @column_map end |
#filename ⇒ Object
Returns the value of attribute filename.
51 52 53 |
# File 'app/services/ecm/blog/import_posts_service.rb', line 51 def filename @filename end |
Class Method Details
.body_source_formats ⇒ Object
47 48 49 |
# File 'app/services/ecm/blog/import_posts_service.rb', line 47 def self.body_source_formats BODY_SOURCE_FORMATS end |
.column_maps ⇒ Object
41 42 43 |
# File 'app/services/ecm/blog/import_posts_service.rb', line 41 def self.column_maps COLUMN_MAPS end |