mercator_icecat 0.0.1 → 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +11 -0
  3. data/app/controllers/admin/metadata_controller.rb +14 -0
  4. data/app/models/mercator_icecat/access.rb +48 -0
  5. data/app/models/mercator_icecat/metadatum.rb +393 -0
  6. data/app/models/product_extensions.rb +28 -0
  7. data/app/views/layouts/mercator_icecat/application.html.erb +10 -11
  8. data/app/views/taglibs/admin/metadatum.dryml +117 -0
  9. data/config/routes.rb +4 -1
  10. data/db/migrate/20131219141435_create_toners.rb +42 -0
  11. data/db/migrate/20140411135444_change_icecat_metadata.rb +25 -0
  12. data/db/migrate/20140413123018_add_index_to_prod_id_in_icecat_metadata.rb +9 -0
  13. data/db/migrate/20140414141008_add_icacat_id_to_product_group.rb +9 -0
  14. data/db/migrate/20140415111836_add_icecat_id_to_property.rb +9 -0
  15. data/db/migrate/20140415112033_add_indices_for_icecat_id.rb +13 -0
  16. data/db/migrate/20140415122523_change_indices.rb +11 -0
  17. data/db/migrate/20140416065410_add_index_to_icecat_product_id.rb +15 -0
  18. data/lib/mercator_icecat/engine.rb +10 -1
  19. data/lib/mercator_icecat/version.rb +2 -2
  20. data/lib/string_extensions.rb +30 -0
  21. data/lib/tasks/mercator_icecat_tasks.rake +191 -4
  22. data/spec/controllers/mercator_icecat/metadata_controller_spec.rb +5 -0
  23. data/spec/factories/metadatum.rb +18 -0
  24. data/spec/models/mercator_icecat/metadatum_spec.rb +11 -0
  25. data/spec/models/product_spec.rb +5 -0
  26. metadata +79 -85
  27. data/app/helpers/mercator_icecat/application_helper.rb +0 -4
  28. data/test/dummy/README.rdoc +0 -28
  29. data/test/dummy/Rakefile +0 -6
  30. data/test/dummy/app/assets/javascripts/application.js +0 -13
  31. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  32. data/test/dummy/app/controllers/application_controller.rb +0 -5
  33. data/test/dummy/app/helpers/application_helper.rb +0 -2
  34. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  35. data/test/dummy/bin/bundle +0 -3
  36. data/test/dummy/bin/rails +0 -4
  37. data/test/dummy/bin/rake +0 -4
  38. data/test/dummy/config.ru +0 -4
  39. data/test/dummy/config/application.rb +0 -23
  40. data/test/dummy/config/boot.rb +0 -5
  41. data/test/dummy/config/database.yml +0 -25
  42. data/test/dummy/config/environment.rb +0 -5
  43. data/test/dummy/config/environments/development.rb +0 -29
  44. data/test/dummy/config/environments/production.rb +0 -80
  45. data/test/dummy/config/environments/test.rb +0 -36
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  47. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  48. data/test/dummy/config/initializers/inflections.rb +0 -16
  49. data/test/dummy/config/initializers/mime_types.rb +0 -5
  50. data/test/dummy/config/initializers/secret_token.rb +0 -12
  51. data/test/dummy/config/initializers/session_store.rb +0 -3
  52. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  53. data/test/dummy/config/locales/en.yml +0 -23
  54. data/test/dummy/config/routes.rb +0 -4
  55. data/test/dummy/public/404.html +0 -58
  56. data/test/dummy/public/422.html +0 -58
  57. data/test/dummy/public/500.html +0 -57
  58. data/test/dummy/public/favicon.ico +0 -0
  59. data/test/integration/navigation_test.rb +0 -10
  60. data/test/mercator_icecat_test.rb +0 -7
  61. data/test/test_helper.rb +0 -15
@@ -0,0 +1,28 @@
1
+ module ProductExtensions
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :icecat_metadata, :class_name => "MercatorIcecat::Metadatum",
7
+ foreign_key: :product_id, primary_key: :id, inverse_of: :product
8
+
9
+ scope :without_icecat_metadata, -> { includes(:icecat_metadata ).where( icecat_metadata: { product_id: nil } ) }
10
+ end
11
+
12
+ # --- Instance Methods --- #
13
+
14
+ # FIXME! HAS 20140413 This is highly customer specific
15
+ def icecat_article_number
16
+ self.number =~ /^HP-(.+)$/
17
+ $1 || self.number
18
+ end
19
+
20
+ def icecat_vendor
21
+ self.article_number =~ /^HP-(.+)$/
22
+ $1 ? "1" : nil
23
+ end
24
+
25
+ def icecat_product_id
26
+ icecat_metadata.first.icecat_product_id if icecat_metadata.any?
27
+ end
28
+ end
@@ -1,14 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>MercatorIcecat</title>
5
- <%= stylesheet_link_tag "mercator_icecat/application", media: "all" %>
6
- <%= javascript_include_tag "mercator_icecat/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title>Mercator Icecat</title>
5
+ <%= stylesheet_link_tag "mercator_icecat/application", media: "all" %>
6
+ <%= javascript_include_tag "mercator_icecat/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
10
9
 
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,117 @@
1
+ <def tag="card" for="MercatorIcecat::Metadatum">
2
+ <card class="mercator-icecat--metadatum" param="default" merge>
3
+ <header: param>
4
+ <h4 param="heading"><a><name/></a></h4>
5
+ </header:>
6
+ </card>
7
+ </def>
8
+
9
+ <def tag="form" for="MercatorIcecat::Metadatum">
10
+ <form merge param="default">
11
+ <error-messages param/>
12
+ <field-list fields="path, icecat_updated_at, quality, product_number, on_market, model_name, product_view, product" param/>
13
+ <div param="actions">
14
+ <submit label="#{ht 'mercator_icecat/metadatum.actions.save', :default=>['Save']}" param/><or-cancel param="cancel"/>
15
+ </div>
16
+ </form>
17
+ </def>
18
+
19
+ <!-- ====== MercatorIcecat::Metadatum Pages ====== -->
20
+
21
+ <def tag="index-page" for="MercatorIcecat::Metadatum">
22
+ <page merge title="#{ht 'mercator_icecat/metadatum.index.title', :default=>[model.model_name.human(:count=>100)] }">
23
+ <body: class="index-page mercator-icecat--metadatum" param/>
24
+
25
+ <content-header: param>
26
+ <h2 param="heading">
27
+ <ht key="mercator_icecat/metadatum.index.heading">
28
+ <model-name-human model="&model"/>
29
+ </ht>
30
+ </h2>
31
+
32
+ <p param="count" if>
33
+ <ht key="mercator_icecat/metadatum.collection.count" count="&collection_count">
34
+ <count summary/>
35
+ </ht>
36
+ </p>
37
+ </content-header:>
38
+
39
+ <content-body: param>
40
+ <a action="new" to="&model" param="new-link">
41
+ <ht key="mercator_icecat/metadatum.actions.new/" />
42
+ </a>
43
+
44
+ <page-nav param="top-page-nav"/>
45
+
46
+ <collection param/>
47
+
48
+ <page-nav param="bottom-page-nav"/>
49
+
50
+
51
+ </content-body:>
52
+ </page>
53
+ </def>
54
+
55
+
56
+ <def tag="new-page" for="MercatorIcecat::Metadatum">
57
+ <page merge title="#{ht 'mercator_icecat/metadatum.new.title', :default=>[' New Metadatum'] }">
58
+ <body: class="new-page mercator-icecat--metadatum" param/>
59
+
60
+ <content-header: param>
61
+ <h2 param="heading">
62
+ <ht key="mercator_icecat/metadatum.new.heading"/>
63
+ </h2>
64
+ </content-header:>
65
+
66
+ <content-body: param>
67
+ <form param>
68
+ <submit: label="#{ht 'mercator_icecat/metadatum.actions.create', :default=>['Create Metadatum']}"/>
69
+ </form>
70
+ </content-body:>
71
+ </page>
72
+ </def>
73
+
74
+
75
+ <def tag="show-page" for="MercatorIcecat::Metadatum">
76
+ <page merge title="#{ht 'mercator_icecat/metadatum.show.title', :default=>['Metadatum'], :name => name(:no_wrapper => true) }" without-aside >
77
+
78
+ <body: class="show-page mercator-icecat--metadatum" param/>
79
+
80
+ <content-header: param>
81
+ <h2 param="heading">
82
+ <ht key="mercator_icecat/metadatum.show.heading" name="#{name(:no_wrapper => true)}"/>
83
+ </h2>
84
+
85
+ <record-flags fields="" param/>
86
+
87
+ <a action="edit" if="&can_edit?" param="edit-link">
88
+ <ht key="mercator_icecat/metadatum.actions.edit" name="#{name(:no_wrapper => true)}"/>
89
+ </a>
90
+ </content-header:>
91
+
92
+ <content-body: param>
93
+ <field-list fields="path, icecat_updated_at, quality, product_number, on_market, model_name, product_view, product" param/>
94
+ </content-body:>
95
+
96
+ </page>
97
+ </def>
98
+
99
+
100
+ <def tag="edit-page" for="MercatorIcecat::Metadatum">
101
+ <page merge title="#{ht 'mercator_icecat/metadatum.edit.title', :default=>['Edit Metadatum'], :name => name(:no_wrapper => true) }">
102
+
103
+ <body: class="edit-page mercator-icecat--metadatum" param/>
104
+
105
+ <content-header: param>
106
+ <h2 param="heading">
107
+ <ht key="mercator_icecat/metadatum.edit.heading" name="#{name(:no_wrapper => true)}"/>
108
+ </h2>
109
+ <delete-button label="#{ht 'mercator_icecat/metadatum.actions.delete', :default=>['Remove This Metadatum']}" param/>
110
+ </content-header:>
111
+
112
+ <content-body: param>
113
+ <form param/>
114
+ </content-body:>
115
+
116
+ </page>
117
+ </def>
@@ -1,2 +1,5 @@
1
- MercatorIcecat::Engine.routes.draw do
1
+ Mercator::Application.routes.draw do
2
+ namespace :admin do
3
+ resources :metadata
4
+ end
2
5
  end
@@ -0,0 +1,42 @@
1
+ class CreateToners < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :toners do |t|
4
+ t.string :article_number
5
+ t.string :description
6
+ t.string :vendor_number
7
+ t.decimal :price, :precision => 10, :scale => 2
8
+ t.datetime :created_at
9
+ t.datetime :updated_at
10
+ end
11
+
12
+ change_column :prices, :value, :decimal, :limit => nil, :precision => 10, :scale => 2
13
+ change_column :prices, :vat, :decimal, :limit => nil, :precision => 10, :scale => 2
14
+ change_column :prices, :scale_from, :decimal, :limit => nil, :precision => 10, :scale => 2
15
+ change_column :prices, :scale_to, :decimal, :limit => nil, :precision => 10, :scale => 2
16
+
17
+ change_column :inventories, :amount, :decimal, :limit => nil, :precision => 10, :scale => 2
18
+ change_column :inventories, :weight, :decimal, :limit => nil, :precision => 10, :scale => 2
19
+
20
+ change_column :lineitems, :amount, :decimal, :limit => nil, :precision => 10, :scale => 2
21
+ change_column :lineitems, :vat, :decimal, :limit => nil, :precision => 10, :scale => 2
22
+
23
+ change_column :properties, :value, :decimal, :limit => nil, :precision => 10, :scale => 2
24
+ end
25
+
26
+ def self.down
27
+ change_column :prices, :value, :decimal, :precision => 10, :scale => 0
28
+ change_column :prices, :vat, :decimal, :precision => 10, :scale => 0
29
+ change_column :prices, :scale_from, :decimal, :precision => 10, :scale => 0
30
+ change_column :prices, :scale_to, :decimal, :precision => 10, :scale => 0
31
+
32
+ change_column :inventories, :amount, :decimal, :precision => 10, :scale => 0
33
+ change_column :inventories, :weight, :decimal, :precision => 10, :scale => 0
34
+
35
+ change_column :lineitems, :amount, :decimal, :precision => 10, :scale => 0
36
+ change_column :lineitems, :vat, :decimal, :precision => 10, :scale => 0
37
+
38
+ change_column :properties, :value, :decimal, :precision => 10, :scale => 0
39
+
40
+ drop_table :toners
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ class ChangeIcecatMetadata < ActiveRecord::Migration
2
+ def self.up
3
+ rename_column :mercator_icecat_metadata, :category_id, :cat_id
4
+ rename_column :mercator_icecat_metadata, :product_name, :model_name
5
+ rename_column :mercator_icecat_metadata, :product_view_id, :product_view
6
+ add_column :mercator_icecat_metadata, :supplier_id, :string
7
+ add_column :mercator_icecat_metadata, :icecat_product_id, :string
8
+ add_column :mercator_icecat_metadata, :prod_id, :string
9
+ change_column :mercator_icecat_metadata, :on_market, :string, :limit => 255
10
+ change_column :mercator_icecat_metadata, :cat_id, :string, :limit => 255
11
+ change_column :mercator_icecat_metadata, :product_view, :string, :limit => 255
12
+ end
13
+
14
+ def self.down
15
+ rename_column :mercator_icecat_metadata, :cat_id, :category_id
16
+ rename_column :mercator_icecat_metadata, :model_name, :product_name
17
+ rename_column :mercator_icecat_metadata, :product_view, :product_view_id
18
+ remove_column :mercator_icecat_metadata, :supplier_id
19
+ remove_column :mercator_icecat_metadata, :icecat_product_id
20
+ remove_column :mercator_icecat_metadata, :prod_id
21
+ change_column :mercator_icecat_metadata, :on_market, :boolean
22
+ change_column :mercator_icecat_metadata, :category_id, :integer
23
+ change_column :mercator_icecat_metadata, :product_view_id, :integer
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ class AddIndexToProdIdInIcecatMetadata < ActiveRecord::Migration
2
+ def self.up
3
+ add_index :mercator_icecat_metadata, [:prod_id]
4
+ end
5
+
6
+ def self.down
7
+ remove_index :mercator_icecat_metadata, :name => :index_mercator_icecat_metadata_on_prod_id rescue ActiveRecord::StatementInvalid
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddIcacatIdToProductGroup < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :property_groups, :icecat_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :property_groups, :icecat_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddIcecatIdToProperty < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :properties, :icecat_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :properties, :icecat_id
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class AddIndicesForIcecatId < ActiveRecord::Migration
2
+ def self.up
3
+ add_index :property_groups, [:icecat_id]
4
+
5
+ add_index :properties, [:icecat_id]
6
+ end
7
+
8
+ def self.down
9
+ remove_index :property_groups, :name => :index_property_groups_on_icecat_id rescue ActiveRecord::StatementInvalid
10
+
11
+ remove_index :properties, :name => :index_properties_on_icecat_id rescue ActiveRecord::StatementInvalid
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ class ChangeIndices < ActiveRecord::Migration
2
+ def self.up
3
+ remove_index :property_groups, :name => :index_property_groups_on_icecat_id rescue ActiveRecord::StatementInvalid
4
+ add_index :property_groups, [:icecat_id], :unique => true
5
+ end
6
+
7
+ def self.down
8
+ remove_index :property_groups, :name => :index_property_groups_on_icecat_id rescue ActiveRecord::StatementInvalid
9
+ add_index :property_groups, [:icecat_id]
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ class AddIndexToIcecatProductId < ActiveRecord::Migration
2
+ def self.up
3
+ remove_index :properties, :name => :index_properties_on_icecat_id rescue ActiveRecord::StatementInvalid
4
+ add_index :properties, [:icecat_id], :unique => true
5
+
6
+ add_index :mercator_icecat_metadata, [:icecat_product_id]
7
+ end
8
+
9
+ def self.down
10
+ remove_index :properties, :name => :index_properties_on_icecat_id rescue ActiveRecord::StatementInvalid
11
+ add_index :properties, [:icecat_id]
12
+
13
+ remove_index :mercator_icecat_metadata, :name => :index_mercator_icecat_metadata_on_icecat_product_id rescue ActiveRecord::StatementInvalid
14
+ end
15
+ end
@@ -1,5 +1,14 @@
1
1
  module MercatorIcecat
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace MercatorIcecat
4
+
5
+ config.icecat = true
6
+
7
+ config.generators do |g|
8
+ g.test_framework :rspec, :fixture => false
9
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
10
+ g.assets false
11
+ g.helper false
12
+ end
4
13
  end
5
- end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module MercatorIcecat
2
- VERSION = "0.0.1"
3
- end
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ class String
2
+ def fix_utf8
3
+ string = self
4
+ string = string.gsub(/\xC4\xB1/, '-')
5
+ string = string.gsub(/\xC5\xA3/, '-')
6
+ string = string.gsub(/\xCE\xBC/, '-')
7
+ string = string.gsub(/\xD0\xA1/, '-')
8
+ string = string.gsub(/\xD0\xB1/, '-')
9
+ string = string.gsub(/\xD0\xBC/, '-')
10
+ string = string.gsub(/\xD1\x85/, '-')
11
+
12
+ string = string.gsub(/\xE2\x80\x8E/, '-')
13
+ string = string.gsub(/\xE2\x80\x90/, '-')
14
+ string = string.gsub(/\xE2\x80\x91/, '-')
15
+ string = string.gsub(/\xE2\x89\xA4/, '-')
16
+ string = string.gsub(/\xE2\x97\x8B/, '-')
17
+ string = string.gsub(/\xEF\xAC\x81/, '-')
18
+ string = string.gsub(/\xEF\xBF\xBD/, 'ä')
19
+ # string = string.gsub(//, '-')
20
+ return string
21
+ end
22
+
23
+ def icecat_datatype
24
+ return "flag" if ["N", "Y"].include? self
25
+ if (( self.to_f.to_s == self ) || ( self.to_i.to_s == self )) && self.to_i < 10000000
26
+ return "numeric"
27
+ end
28
+ return "textual"
29
+ end
30
+ end
@@ -1,4 +1,191 @@
1
- # desc "Explaining what the task does"
2
- # task :mercator_icecat do
3
- # # Task goes here
4
- # end
1
+ namespace :icecat do
2
+ namespace :metadata do
3
+
4
+ # starten als: 'bundle exec rake icecat:metadata:import_full'
5
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:import_full RAILS_ENV=production'
6
+ desc 'Import metadata from Icecat '
7
+ task :import_full => :environment do
8
+
9
+ ::JobLogger.info("=" * 50)
10
+ ::JobLogger.info("Started Job: icecat:metadata:import_full")
11
+ MercatorIcecat::Metadatum.import(full: true)
12
+ ::JobLogger.info("Finished Job: icecat:metadata:import_full")
13
+ ::JobLogger.info("=" * 50)
14
+ end
15
+
16
+ # starten als: 'bundle exec rake icecat:metadata:import_daily'
17
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:import_daily RAILS_ENV=production'
18
+ desc 'Import metadata from Icecat '
19
+ task :import_daily => :environment do
20
+
21
+ ::JobLogger.info("=" * 50)
22
+ ::JobLogger.info("Started Job: icecat:metadata:import_daily")
23
+ MercatorIcecat::Metadatum.import(date: Date.today)
24
+ ::JobLogger.info("Finished Job: icecat:metadata:import_daily")
25
+ ::JobLogger.info("=" * 50)
26
+ end
27
+
28
+ # starten als: 'bundle exec rake icecat:metadata:assign_products'
29
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:assign_products RAILS_ENV=production'
30
+ desc 'Assign Products to Metadata '
31
+ task :assign_products => :environment do
32
+
33
+ ::JobLogger.info("=" * 50)
34
+ ::JobLogger.info("Started Job: icecat:metadata:assign_products")
35
+ MercatorIcecat::Metadatum.assign_products(only_missing: true)
36
+ ::JobLogger.info("Finished Job: icecat:metadata:assign_products")
37
+ ::JobLogger.info("=" * 50)
38
+ end
39
+
40
+ # starten als: 'bundle exec rake icecat:metadata:download_and_overwrite_xml'
41
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:download_and_overwrite_xml RAILS_ENV=production'
42
+ desc 'Import and overwrite all XML files '
43
+ task :download_and_overwrite_xml => :environment do
44
+
45
+ ::JobLogger.info("=" * 50)
46
+ ::JobLogger.info("Started Job: icecat:metadata:download_and_overwrite_xml")
47
+ MercatorIcecat::Metadatum.download(overwrite: true, from_today: false)
48
+ ::JobLogger.info("Finished Job: icecat:metadata:download_and_overwrite_xml")
49
+ ::JobLogger.info("=" * 50)
50
+ end
51
+
52
+ # starten als: 'bundle exec rake icecat:metadata:download_daily_xml'
53
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:download_daily_xml RAILS_ENV=production'
54
+ desc 'Import the XML files from the last 25 hours'
55
+ task :download_daily_xml => :environment do
56
+
57
+ ::JobLogger.info("=" * 50)
58
+ ::JobLogger.info("Started Job: icecat:metadata:download_daily_xml")
59
+ MercatorIcecat::Metadatum.download(overwrite: true, from_today: true)
60
+ ::JobLogger.info("Finished Job: icecat:metadata:download_daily_xml")
61
+ ::JobLogger.info("=" * 50)
62
+ end
63
+
64
+ # starten als: 'bundle exec rake icecat:metadata:update_products'
65
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:update_products RAILS_ENV=production'
66
+ desc 'Update all products, properties, property groups and values from downloaded XML files.'
67
+ task :update_products => :environment do
68
+
69
+ ::JobLogger.info("=" * 50)
70
+ ::JobLogger.info("Started Job: icecat:metadata:update_products")
71
+ MercatorIcecat::Metadatum.update_products(from_today: false)
72
+ ::JobLogger.info("Finished Job: icecat:metadata:update_products")
73
+ ::JobLogger.info("=" * 50)
74
+ end
75
+
76
+ # starten als: 'bundle exec rake icecat:metadata:update_todays_products'
77
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:update_todays_products RAILS_ENV=production'
78
+ desc 'Update todays products, properties, property groups and values from downloaded XML files.'
79
+ task :update_todays_products => :environment do
80
+
81
+ ::JobLogger.info("=" * 50)
82
+ ::JobLogger.info("Started Job: icecat:metadata:update_todays_products")
83
+ MercatorIcecat::Metadatum.update_products(from_today: true)
84
+ ::JobLogger.info("Finished Job: icecat:metadata:update_todays_products")
85
+ ::JobLogger.info("=" * 50)
86
+ end
87
+
88
+ # starten als: 'bundle exec rake icecat:metadata:update_product_relations'
89
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:update_product_relations RAILS_ENV=production'
90
+ desc 'Update product relations from downloaded XML files.'
91
+ task :update_product_relations => :environment do
92
+
93
+ ::JobLogger.info("=" * 50)
94
+ ::JobLogger.info("Started Job: icecat:metadata:update_product_relations")
95
+ MercatorIcecat::Metadatum.update_product_relations(from_today: false)
96
+ ::JobLogger.info("Finished Job: icecat:metadata:update_product_relations")
97
+ ::JobLogger.info("=" * 50)
98
+ end
99
+
100
+ # starten als: 'bundle exec rake icecat:metadata:update_todays_product_relations'
101
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:update_todays_product_relations RAILS_ENV=production'
102
+ desc 'Update todays product relations from downloaded XML files.'
103
+ task :update_todays_product_relations => :environment do
104
+
105
+ ::JobLogger.info("=" * 50)
106
+ ::JobLogger.info("Started Job: icecat:metadata:update_todays_product_relations")
107
+ MercatorIcecat::Metadatum.update_product_relations(from_today: true)
108
+ ::JobLogger.info("Finished Job: icecat:metadata:update_todays_product_relations")
109
+ ::JobLogger.info("=" * 50)
110
+ end
111
+
112
+ # starten als: 'bundle exec rake icecat:metadata:import_missing_images'
113
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:import_missing_images RAILS_ENV=production'
114
+ desc 'Import missing imiages.'
115
+ task :import_missing_images => :environment do
116
+
117
+ ::JobLogger.info("=" * 50)
118
+ ::JobLogger.info("Started Job: icecat:metadata:import_missing_images")
119
+ MercatorIcecat::Metadatum.import_missing_images
120
+ ::JobLogger.info("Finished Job: icecat:metadata:import_missing_images")
121
+ ::JobLogger.info("=" * 50)
122
+ end
123
+
124
+ # starten als: 'bundle exec rake icecat:metadata:daily_update'
125
+ # in Produktivumgebungen: 'bundle exec rake icecat:metadata:daily_update RAILS_ENV=production'
126
+ desc 'Daily Update '
127
+ task :daily_update => :environment do
128
+ # The first daily run after installation re-downloads all xml files, that's OK.
129
+
130
+ ::JobLogger.info("=" * 50)
131
+ ::JobLogger.info("Started Job: icecat:catalog:daily_update")
132
+
133
+ ::JobLogger.info("Started Task: icecat:catalog:download_daily")
134
+ MercatorIcecat::Access.download_index(full: false)
135
+ ::JobLogger.info("Finished Task: icecat:catalog:download_daily")
136
+
137
+ ::JobLogger.info("Started Task: icecat:metadata:import_daily")
138
+ MercatorIcecat::Metadatum.import(date: Date.today)
139
+ ::JobLogger.info("Finished Task: icecat:metadata:import_daily")
140
+
141
+ ::JobLogger.info("Started Task: icecat:metadata:assign_products")
142
+ MercatorIcecat::Metadatum.assign_products(only_missing: true)
143
+ ::JobLogger.info("Finished Task: icecat:metadata:assign_products")
144
+
145
+ ::JobLogger.info("Started Task: icecat:metadata:download_daily_xml")
146
+ MercatorIcecat::Metadatum.download(overwrite: true, from_today: true)
147
+ ::JobLogger.info("Finished Task: icecat:metadata:download_daily_xml")
148
+
149
+ ::JobLogger.info("Started Task: icecat:metadata:update_todays_products")
150
+ MercatorIcecat::Metadatum.update_products(from_today: true)
151
+ ::JobLogger.info("Finished Task: icecat:metadata:update_todays_products")
152
+
153
+ ::JobLogger.info("Started Task: icecat:metadata:update_product_relations")
154
+ MercatorIcecat::Metadatum.update_product_relations(from_today: true)
155
+ ::JobLogger.info("Finished Task: icecat:metadata:update_product_relations")
156
+
157
+ ::JobLogger.info("Started Task: icecat:metadata:import_missing_images")
158
+ MercatorIcecat::Metadatum.import_missing_images
159
+ ::JobLogger.info("Finished Task: icecat:metadata:import_missing_images")
160
+
161
+ ::JobLogger.info("Finished Job: icecat:catalog:daily_update")
162
+ ::JobLogger.info("=" * 50)
163
+ end
164
+ end
165
+
166
+ namespace :catalog do
167
+ # starten als: 'bundle exec rake icecat:catalog:download_full'
168
+ # in Produktivumgebungen: 'bundle exec rake icecat:catalog:download_full RAILS_ENV=production'
169
+ desc 'Download full catalog index from Icecat '
170
+ task :download_full => :environment do
171
+
172
+ ::JobLogger.info("=" * 50)
173
+ ::JobLogger.info("Started Job: icecat:catalog:download_full")
174
+ MercatorIcecat::Access.download_index(full: true)
175
+ ::JobLogger.info("Finished Job: icecat:catalog:download_full")
176
+ ::JobLogger.info("=" * 50)
177
+ end
178
+
179
+ # starten als: 'bundle exec rake icecat:catalog:download_daily'
180
+ # in Produktivumgebungen: 'bundle exec rake icecat:catalog:download_daily RAILS_ENV=production'
181
+ desc 'Download daily catalog index from Icecat '
182
+ task :download_daily => :environment do
183
+
184
+ ::JobLogger.info("=" * 50)
185
+ ::JobLogger.info("Started Job: icecat:catalog:download_daily")
186
+ MercatorIcecat::Access.download_index(full: false)
187
+ ::JobLogger.info("Finished Job: icecat:catalog:download_daily")
188
+ ::JobLogger.info("=" * 50)
189
+ end
190
+ end
191
+ end