diff options
| -rw-r--r-- | app/controllers/api/v1/netex_imports_controller.rb | 3 | ||||
| -rw-r--r-- | app/services/http_service.rb | 2 | ||||
| -rw-r--r-- | app/workers/workbench_import_worker.rb | 2 | ||||
| -rw-r--r-- | db/schema.rb | 22 | ||||
| -rw-r--r-- | lib/referential_metadata_kludge.rb | 17 |
5 files changed, 35 insertions, 11 deletions
diff --git a/app/controllers/api/v1/netex_imports_controller.rb b/app/controllers/api/v1/netex_imports_controller.rb index 17eec2ef8..ba7777654 100644 --- a/app/controllers/api/v1/netex_imports_controller.rb +++ b/app/controllers/api/v1/netex_imports_controller.rb @@ -40,6 +40,9 @@ module Api organisation_id: @workbench.organisation_id, workbench_id: @workbench.id) @new_referential.save! + # TODO: >>> REMOVE ME !!!! + ReferentialMetadataKludge.make_metadata_from_name! netex_import_params['name'], referential_id: @new_referential.id + # <<< REMOVE ME !!!! rescue ActiveRecord::RecordInvalid render json: {errors: @new_referential.errors}, status: 406 finish_action! diff --git a/app/services/http_service.rb b/app/services/http_service.rb index ae7d0e413..ceaa89b2f 100644 --- a/app/services/http_service.rb +++ b/app/services/http_service.rb @@ -39,6 +39,8 @@ module HTTPService extend self params.update( name => Faraday::UploadIO.new(value, mime_type, as_name ) ) end + require 'pry' + binding.pry return c.post path, params end end diff --git a/app/workers/workbench_import_worker.rb b/app/workers/workbench_import_worker.rb index 7f77b46dc..6fc709d51 100644 --- a/app/workers/workbench_import_worker.rb +++ b/app/workers/workbench_import_worker.rb @@ -45,6 +45,8 @@ class WorkbenchImportWorker def try_upload_entry_group eg_name, eg_stream result = execute_post eg_name, eg_stream + require 'pry' + binding.pry return result if result && result.status < 400 @response = result.body try_again diff --git a/db/schema.rb b/db/schema.rb index 01ed67d77..f9b2ebc69 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -286,12 +286,12 @@ ActiveRecord::Schema.define(version: 20170808110333) do t.datetime "started_at" t.datetime "ended_at" t.string "token_download" - t.string "type" + t.string "type", limit: 255 t.integer "parent_id", limit: 8 t.string "parent_type" + t.integer "current_step", default: 0 + t.integer "total_steps", default: 0 t.datetime "notified_parent_at" - t.integer "current_step", default: 0 - t.integer "total_steps", default: 0 end add_index "imports", ["referential_id"], name: "index_imports_on_referential_id", using: :btree @@ -615,7 +615,7 @@ ActiveRecord::Schema.define(version: 20170808110333) do create_table "stop_areas", id: :bigserial, force: :cascade do |t| t.integer "parent_id", limit: 8 - t.string "objectid", null: false + t.string "objectid", null: false t.integer "object_version", limit: 8 t.string "creator_id" t.string "name" @@ -624,8 +624,8 @@ ActiveRecord::Schema.define(version: 20170808110333) do t.string "registration_number" t.string "nearest_topic_name" t.integer "fare_code" - t.decimal "longitude", precision: 19, scale: 16 - t.decimal "latitude", precision: 19, scale: 16 + t.decimal "longitude", precision: 19, scale: 16 + t.decimal "latitude", precision: 19, scale: 16 t.string "long_lat_type" t.string "country_code" t.string "street_name" @@ -643,7 +643,7 @@ ActiveRecord::Schema.define(version: 20170808110333) do t.datetime "deleted_at" t.datetime "created_at" t.datetime "updated_at" - t.string "stif_type" + t.string "stif_type", limit: 255 end add_index "stop_areas", ["name"], name: "index_stop_areas_on_name", using: :btree @@ -714,18 +714,18 @@ ActiveRecord::Schema.define(version: 20170808110333) do add_index "time_table_periods", ["time_table_id"], name: "index_time_table_periods_on_time_table_id", using: :btree create_table "time_tables", id: :bigserial, force: :cascade do |t| - t.string "objectid", null: false - t.integer "object_version", limit: 8, default: 1 + t.string "objectid", null: false + t.integer "object_version", limit: 8, default: 1 t.string "creator_id" t.string "version" t.string "comment" - t.integer "int_day_types", default: 0 + t.integer "int_day_types", default: 0 t.date "start_date" t.date "end_date" t.integer "calendar_id", limit: 8 t.datetime "created_at" t.datetime "updated_at" - t.string "color" + t.string "color", limit: 255 t.integer "created_from_id" t.string "checksum" t.text "checksum_source" diff --git a/lib/referential_metadata_kludge.rb b/lib/referential_metadata_kludge.rb new file mode 100644 index 000000000..525b471ad --- /dev/null +++ b/lib/referential_metadata_kludge.rb @@ -0,0 +1,17 @@ +module ReferentialMetadataKludge extend self + + def make_metadata_from_name!( name, referential_id: ) + ReferentialMetadata.create!( + referential_id: referential_id, + line_ids: [107, 108], + periodes: name_to_periods(name)) + end + + def name_to_periods name + {'offre1' => [Date.new(2017,3,1)...Date.new(2017,4,1)], + 'offre2' => [Date.new(2017,3,1)...Date.new(2018,1,1)], + 'OFFRE_TRANSDEV_20170301122517' => [Date.new(2017,3,1)...Date.new(2017,4,1)], + 'OFFRE_TRANSDEV_20170301122519' => [Date.new(2017,3,1)...Date.new(2018,1,1)]}.fetch name + end + +end |
