apidae 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/apidae/import_controller.rb +19 -12
  3. data/app/models/apidae/application_record.rb +5 -0
  4. data/app/models/apidae/object.rb +37 -21
  5. data/app/models/apidae/selection.rb +16 -5
  6. data/app/models/apidae/selection_object.rb +6 -0
  7. data/db/migrate/20170512212941_create_apidae_selections.rb +1 -1
  8. data/db/migrate/20170512214641_create_apidae_objects.rb +1 -1
  9. data/db/migrate/20170512221525_create_apidae_objects_apidae_selections.rb +1 -1
  10. data/db/migrate/20170513114002_create_apidae_towns.rb +1 -1
  11. data/db/migrate/20170513114409_add_town_insee_code_to_objects.rb +1 -1
  12. data/db/migrate/20170513115401_add_pictures_data_to_objects.rb +1 -1
  13. data/db/migrate/20170513121215_create_apidae_attached_files.rb +1 -1
  14. data/db/migrate/20170513205932_rename_objects_selections_table.rb +1 -1
  15. data/db/migrate/20170720161134_add_entity_data_to_objects.rb +1 -1
  16. data/db/migrate/20170730102424_create_apidae_file_imports.rb +1 -1
  17. data/db/migrate/20171025075304_create_apidae_exports.rb +1 -1
  18. data/db/migrate/20180217222410_create_apidae_selection_objects.rb +10 -0
  19. data/db/migrate/20180218172704_change_text_columns_to_json.rb +10 -0
  20. data/db/migrate/20180218231319_add_service_data_to_apidae_objects.rb +5 -0
  21. data/lib/apidae/version.rb +1 -1
  22. data/test/dummy/config/application.rb +0 -3
  23. data/test/dummy/db/schema.rb +70 -64
  24. data/test/dummy/log/development.log +95 -0
  25. data/test/fixtures/apidae/selection_objects.yml +9 -0
  26. data/test/models/apidae/selection_object_test.rb +9 -0
  27. metadata +12 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bd8c7a992f4c7d76fd4255d90c737506c0b9b4d
4
- data.tar.gz: ef8dccc6e6af2d9aef146bb03164ec89f4394db0
3
+ metadata.gz: d0a3a4373bd30afc262811bcf084f5c6d047b064
4
+ data.tar.gz: 18bd22b43a8ac17470a989cc7c9d5fc05e8fc0f1
5
5
  SHA512:
6
- metadata.gz: 3dc86f15ac98ebcf52b5cd3f2218ee5ec88460908db06b80226660932f7bf4539c1ade07fbb833bad11bfa10d1aa9254adc3115171fba1e7387d9da66c8dd99e
7
- data.tar.gz: d9fb909de8cabe9d2175b86d38e178006a089399f438a22ef477a11247ba7d8904e6540fb7a9063b4350d52abf3ca8c514b7e67aae57c24913281cf8fad42a13
6
+ metadata.gz: 6b84b9f9ecf1c2dbbf66ec0d4b31ed9faac0556094b9c1fd53c66a9a4810b663cd4e5295ba1e21210024a7f2069ed342c87738e8eb5f1afd1613cf093d4e2488
7
+ data.tar.gz: acbbbb5cb56bfac471ed1a36cb7bc171bdc3260ef592aa8a2cd457aeb1183e3b1e04130d834f9beabd2ceb0ba48736ca91cec8c71cb6d8783e7a0f23590f21f9
@@ -33,20 +33,27 @@ module Apidae
33
33
  def run
34
34
  success = true
35
35
  Export.pending.each do |e|
36
- open(e.file_url) do |f|
37
- begin
38
- FileImport.import(f)
39
- uri = URI(e.confirm_url)
40
- req = Net::HTTP::Post.new(uri)
41
- Net::HTTP.start(uri.hostname, uri.port) do |http|
42
- http.request(req)
36
+ begin
37
+ open(e.file_url) do |f|
38
+ begin
39
+ FileImport.import(f)
40
+ uri = URI(e.confirm_url)
41
+ req = Net::HTTP::Post.new(uri)
42
+ Net::HTTP.start(uri.hostname, uri.port) do |http|
43
+ http.request(req)
44
+ end
45
+ e.update(status: Export::COMPLETE)
46
+ rescue Exception => ex
47
+ logger.error("Failed to import export file : #{e.file_url}")
48
+ logger.error("Error is : #{ex} \n#{ex.backtrace.join("\n") unless ex.backtrace.blank?}")
49
+ success = false
43
50
  end
44
- e.update(status: Export::COMPLETE)
45
- rescue Exception => ex
46
- logger.error("Failed to retrieve export file : #{ex.file_url}")
47
- logger.error("Error is : #{ex}")
48
- success = false
49
51
  end
52
+ rescue OpenURI::HTTPError => err
53
+ logger.error("Failed to download export file : #{e.file_url}")
54
+ logger.error("Error is : #{err}")
55
+ success = false
56
+ e.update(status: Export::CANCELLED)
50
57
  end
51
58
  end
52
59
  render nothing: true, status: (success ? :ok : :internal_server_error)
@@ -0,0 +1,5 @@
1
+ module Apidae
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -1,16 +1,17 @@
1
1
  module Apidae
2
2
  class Object < ActiveRecord::Base
3
3
 
4
- belongs_to :town, :class_name => 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code
5
- has_many :attached_files, :class_name => 'Apidae::AttachedFile'
6
- has_and_belongs_to_many :selections, :class_name => 'Apidae::Selection'
7
-
8
- store :pictures_data, accessors: [:pictures], coder: JSON
9
- store :type_data, accessors: [:categories, :themes], coder: JSON
10
- store :entity_data, accessors: [:entity_id, :entity_name]
11
- store :contact, accessors: [:telephone, :email, :website], coder: JSON
12
- store :address, accessors: [:address_fields], coder: JSON
13
- store :openings, accessors: [:description, :opening_periods], coder: JSON
4
+ belongs_to :town, class_name: 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code
5
+ has_many :attached_files, class_name: 'Apidae::AttachedFile'
6
+ has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_object_id
7
+ has_many :selections, class_name: 'Apidae::Selection', source: :apidae_selection, through: :apidae_selection_objects
8
+
9
+ store_accessor :pictures_data, :pictures
10
+ store_accessor :type_data, :categories, :themes, :capacite, :classement
11
+ store_accessor :entity_data, :entity_id, :entity_name
12
+ store_accessor :contact, :telephone, :email, :website
13
+ store_accessor :address, :address_fields
14
+ store_accessor :openings, :description, :opening_periods
14
15
 
15
16
  ACT = 'ACTIVITE'
16
17
  COS = 'COMMERCE_ET_SERVICE'
@@ -60,7 +61,7 @@ module Apidae
60
61
  def self.update_object(apidae_obj, object_data)
61
62
  type_fields = TYPES_DATA[object_data[:type]]
62
63
  apidae_obj.apidae_type = object_data[:type]
63
- apidae_obj.apidae_subtype = node_value(object_data[type_fields[:node]], object_data[type_fields[:subtype]])
64
+ apidae_obj.apidae_subtype = node_id(object_data[type_fields[:node]], type_fields[:subtype])
64
65
  apidae_obj.title = node_value(object_data, :nom)
65
66
  apidae_obj.short_desc = node_value(object_data[:presentation], :descriptifCourt)
66
67
  apidae_obj.long_desc = node_value(object_data[:presentation], :descriptifDetaille)
@@ -75,6 +76,7 @@ module Apidae
75
76
  apidae_obj.type_data = object_data[type_fields[:node]]
76
77
  apidae_obj.pictures_data = pictures_urls(object_data[:illustrations])
77
78
  apidae_obj.entity_data = entity_fields(object_data[:informations])
79
+ apidae_obj.service_data = object_data[:prestations]
78
80
  apidae_obj.save!
79
81
  end
80
82
 
@@ -112,24 +114,30 @@ module Apidae
112
114
 
113
115
  def self.address(address_hash)
114
116
  computed_address = []
115
- computed_address << address_hash[:adresse1] unless address_hash[:adresse1].blank?
116
- computed_address << address_hash[:adresse2] unless address_hash[:adresse2].blank?
117
- computed_address << address_hash[:adresse3] unless address_hash[:adresse3].blank?
117
+ unless address_hash.blank?
118
+ computed_address << address_hash[:adresse1] unless address_hash[:adresse1].blank?
119
+ computed_address << address_hash[:adresse2] unless address_hash[:adresse2].blank?
120
+ computed_address << address_hash[:adresse3] unless address_hash[:adresse3].blank?
121
+ end
118
122
  {address_fields: computed_address}
119
123
  end
120
124
 
121
- def self.town(address_hash)
122
- address_hash[:commune] ? Town.find_by_apidae_id(address_hash[:commune][:id]) : nil
125
+ def self.town(address_hash = {})
126
+ (!address_hash.blank? && address_hash[:commune]) ? Town.find_by_apidae_id(address_hash[:commune][:id]) : nil
123
127
  end
124
128
 
125
129
  def self.latitude(location_hash)
126
- geoloc_details = location_hash[:geolocalisation]
127
- (geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][1] : nil
130
+ unless location_hash.blank?
131
+ geoloc_details = location_hash[:geolocalisation]
132
+ (geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][1] : nil
133
+ end
128
134
  end
129
135
 
130
- def self.longitude(location_hash)
131
- geoloc_details = location_hash[:geolocalisation]
132
- (geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][0] : nil
136
+ def self.longitude(location_hash = {})
137
+ unless location_hash.blank?
138
+ geoloc_details = location_hash[:geolocalisation]
139
+ (geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][0] : nil
140
+ end
133
141
  end
134
142
 
135
143
  def self.openings(openings_hash)
@@ -185,5 +193,13 @@ module Apidae
185
193
  ''
186
194
  end
187
195
  end
196
+
197
+ def self.node_id(node, key)
198
+ if node && node[key]
199
+ node[key][:id]
200
+ else
201
+ ''
202
+ end
203
+ end
188
204
  end
189
205
  end
@@ -1,6 +1,7 @@
1
1
  module Apidae
2
2
  class Selection < ActiveRecord::Base
3
- has_and_belongs_to_many :objects, :class_name => 'Apidae::Object'
3
+ has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_selection_id
4
+ has_many :objects, class_name: 'Apidae::Object', source: :apidae_object, through: :apidae_selection_objects
4
5
 
5
6
  MAX_COUNT = 100
6
7
  MAX_LOOPS = 10
@@ -14,19 +15,21 @@ module Apidae
14
15
  apidae_sel.label = selection_data[:nom]
15
16
  apidae_sel.save!
16
17
 
18
+ # Note : should be done with basic collection assignment, but can't make it work...
17
19
  current_objs = apidae_sel.objects.collect {|obj| obj.apidae_id}
18
20
  imported_objs = selection_data[:objetsTouristiques].blank? ? [] : selection_data[:objetsTouristiques].collect {|obj| obj[:id]}
21
+
19
22
  added = imported_objs - current_objs
20
23
  removed = current_objs - imported_objs
21
24
 
22
25
  added.each do |o|
23
- apidae_object = Apidae::Object.find_by_apidae_id(o)
24
- apidae_sel.objects << apidae_object if apidae_object
26
+ obj = Apidae::Object.find_by_apidae_id(o)
27
+ Apidae::SelectionObject.create(apidae_selection_id: apidae_sel.id, apidae_object_id: obj.id)
25
28
  end
26
29
 
27
30
  removed.each do |o|
28
- apidae_object = Apidae::Object.find_by_apidae_id(o)
29
- apidae_sel.objects.delete(apidae_object) if apidae_object
31
+ obj = Apidae::Object.find_by_apidae_id(o)
32
+ Apidae::SelectionObject.destroy(apidae_selection_id: apidae_sel.id, apidae_object_id: obj.id)
30
33
  end
31
34
  end
32
35
 
@@ -65,6 +68,14 @@ module Apidae
65
68
  agenda_entries
66
69
  end
67
70
 
71
+ def results(where_clause, offset, size)
72
+ objects.includes(:town).limit(size).offset(offset).where(where_clause)
73
+ end
74
+
75
+ def total(where_clause)
76
+ objects.where(where_clause).count
77
+ end
78
+
68
79
  private
69
80
 
70
81
  def get_response(config)
@@ -0,0 +1,6 @@
1
+ module Apidae
2
+ class SelectionObject < ApplicationRecord
3
+ belongs_to :apidae_object, class_name: 'Apidae::Object', foreign_key: :apidae_object_id
4
+ belongs_to :apidae_selection, class_name: 'Apidae::Selection', foreign_key: :apidae_selection_id
5
+ end
6
+ end
@@ -1,4 +1,4 @@
1
- class CreateApidaeSelections < ActiveRecord::Migration
1
+ class CreateApidaeSelections < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_selections do |t|
4
4
  t.string :label
@@ -1,4 +1,4 @@
1
- class CreateApidaeObjects < ActiveRecord::Migration
1
+ class CreateApidaeObjects < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_objects do |t|
4
4
  t.string :address
@@ -1,4 +1,4 @@
1
- class CreateApidaeObjectsApidaeSelections < ActiveRecord::Migration
1
+ class CreateApidaeObjectsApidaeSelections < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_objects_apidae_selections do |t|
4
4
  t.integer :object_id
@@ -1,4 +1,4 @@
1
- class CreateApidaeTowns < ActiveRecord::Migration
1
+ class CreateApidaeTowns < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_towns do |t|
4
4
  t.string :country
@@ -1,4 +1,4 @@
1
- class AddTownInseeCodeToObjects < ActiveRecord::Migration
1
+ class AddTownInseeCodeToObjects < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :apidae_objects, :town_insee_code, :string
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddPicturesDataToObjects < ActiveRecord::Migration
1
+ class AddPicturesDataToObjects < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :apidae_objects, :pictures_data, :text
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreateApidaeAttachedFiles < ActiveRecord::Migration
1
+ class CreateApidaeAttachedFiles < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_attached_files do |t|
4
4
  t.string :name
@@ -1,4 +1,4 @@
1
- class RenameObjectsSelectionsTable < ActiveRecord::Migration
1
+ class RenameObjectsSelectionsTable < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  rename_table :apidae_objects_apidae_selections, :apidae_objects_selections
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddEntityDataToObjects < ActiveRecord::Migration
1
+ class AddEntityDataToObjects < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  add_column :apidae_objects, :entity_data, :text
4
4
  end
@@ -1,4 +1,4 @@
1
- class CreateApidaeFileImports < ActiveRecord::Migration
1
+ class CreateApidaeFileImports < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_file_imports do |t|
4
4
  t.string :status
@@ -1,4 +1,4 @@
1
- class CreateApidaeExports < ActiveRecord::Migration
1
+ class CreateApidaeExports < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :apidae_exports do |t|
4
4
  t.string :status
@@ -0,0 +1,10 @@
1
+ class CreateApidaeSelectionObjects < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :apidae_selection_objects do |t|
4
+ t.integer :apidae_selection_id
5
+ t.integer :apidae_object_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class ChangeTextColumnsToJson < ActiveRecord::Migration[5.1]
2
+ def change
3
+ change_column :apidae_objects, :pictures_data, :jsonb, using: 'pictures_data::text::jsonb'
4
+ change_column :apidae_objects, :type_data, :jsonb, using: 'type_data::text::jsonb'
5
+ change_column :apidae_objects, :entity_data, :jsonb, using: 'entity_data::text::jsonb'
6
+ change_column :apidae_objects, :contact, :jsonb, using: 'contact::text::jsonb'
7
+ change_column :apidae_objects, :address, :jsonb, using: 'address::text::jsonb'
8
+ change_column :apidae_objects, :openings, :jsonb, using: 'openings::text::jsonb'
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddServiceDataToApidaeObjects < ActiveRecord::Migration[5.1]
2
+ def change
3
+ add_column :apidae_objects, :service_data, :jsonb
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -18,9 +18,6 @@ module Dummy
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
20
  # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
21
  end
25
22
  end
26
23
 
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  # This file is auto-generated from the current state of the database. Instead
3
2
  # of editing this file, please use the migrations feature of Active Record to
4
3
  # incrementally modify your database, and then regenerate this schema definition.
@@ -11,91 +10,98 @@
11
10
  #
12
11
  # It's strongly recommended that you check this file into your version control system.
13
12
 
14
- ActiveRecord::Schema.define(version: 20171025075304) do
13
+ ActiveRecord::Schema.define(version: 20180218231319) do
15
14
 
16
15
  # These are extensions that must be enabled in order to support this database
17
16
  enable_extension "plpgsql"
18
17
 
19
- create_table "apidae_attached_files", force: :cascade do |t|
20
- t.string "name"
21
- t.string "credits"
22
- t.text "description"
23
- t.integer "apidae_object_id"
24
- t.string "picture_file_name"
25
- t.string "picture_content_type"
26
- t.integer "picture_file_size"
18
+ create_table "apidae_attached_files", id: :serial, force: :cascade do |t|
19
+ t.string "name"
20
+ t.string "credits"
21
+ t.text "description"
22
+ t.integer "apidae_object_id"
23
+ t.string "picture_file_name"
24
+ t.string "picture_content_type"
25
+ t.integer "picture_file_size"
27
26
  t.datetime "picture_updated_at"
28
- t.datetime "created_at", null: false
29
- t.datetime "updated_at", null: false
27
+ t.datetime "created_at", null: false
28
+ t.datetime "updated_at", null: false
30
29
  end
31
30
 
32
- create_table "apidae_exports", force: :cascade do |t|
33
- t.string "status"
34
- t.string "remote_status"
35
- t.boolean "oneshot"
36
- t.boolean "reset"
37
- t.string "file_url"
38
- t.string "confirm_url"
39
- t.integer "project_id"
40
- t.datetime "created_at", null: false
41
- t.datetime "updated_at", null: false
31
+ create_table "apidae_exports", id: :serial, force: :cascade do |t|
32
+ t.string "status"
33
+ t.string "remote_status"
34
+ t.boolean "oneshot"
35
+ t.boolean "reset"
36
+ t.string "file_url"
37
+ t.string "confirm_url"
38
+ t.integer "project_id"
39
+ t.datetime "created_at", null: false
40
+ t.datetime "updated_at", null: false
42
41
  end
43
42
 
44
- create_table "apidae_file_imports", force: :cascade do |t|
45
- t.string "status"
46
- t.string "remote_file"
47
- t.integer "created"
48
- t.integer "updated"
49
- t.integer "deleted"
50
- t.datetime "created_at", null: false
51
- t.datetime "updated_at", null: false
43
+ create_table "apidae_file_imports", id: :serial, force: :cascade do |t|
44
+ t.string "status"
45
+ t.string "remote_file"
46
+ t.integer "created"
47
+ t.integer "updated"
48
+ t.integer "deleted"
49
+ t.datetime "created_at", null: false
50
+ t.datetime "updated_at", null: false
52
51
  end
53
52
 
54
- create_table "apidae_objects", force: :cascade do |t|
55
- t.string "address"
56
- t.integer "apidae_id"
57
- t.string "apidae_type"
58
- t.string "apidae_subtype"
59
- t.string "title"
60
- t.text "short_desc"
61
- t.text "contact"
62
- t.text "long_desc"
63
- t.text "type_data"
64
- t.float "latitude"
65
- t.float "longitude"
66
- t.text "openings"
67
- t.text "rates"
68
- t.text "reservation"
69
- t.datetime "created_at", null: false
70
- t.datetime "updated_at", null: false
71
- t.string "town_insee_code"
72
- t.text "pictures_data"
73
- t.text "entity_data"
53
+ create_table "apidae_objects", id: :serial, force: :cascade do |t|
54
+ t.jsonb "address"
55
+ t.integer "apidae_id"
56
+ t.string "apidae_type"
57
+ t.string "apidae_subtype"
58
+ t.string "title"
59
+ t.text "short_desc"
60
+ t.jsonb "contact"
61
+ t.text "long_desc"
62
+ t.jsonb "type_data"
63
+ t.float "latitude"
64
+ t.float "longitude"
65
+ t.jsonb "openings"
66
+ t.text "rates"
67
+ t.text "reservation"
68
+ t.datetime "created_at", null: false
69
+ t.datetime "updated_at", null: false
70
+ t.string "town_insee_code"
71
+ t.jsonb "pictures_data"
72
+ t.jsonb "entity_data"
73
+ t.jsonb "service_data"
74
74
  end
75
75
 
76
- create_table "apidae_objects_selections", force: :cascade do |t|
76
+ create_table "apidae_objects_selections", id: :serial, force: :cascade do |t|
77
77
  t.integer "object_id"
78
78
  t.integer "selection_id"
79
79
  end
80
80
 
81
- create_table "apidae_selections", force: :cascade do |t|
82
- t.string "label"
83
- t.string "reference"
84
- t.integer "apidae_id"
81
+ create_table "apidae_selection_objects", force: :cascade do |t|
82
+ t.integer "apidae_selection_id"
83
+ t.integer "apidae_object_id"
85
84
  t.datetime "created_at", null: false
86
85
  t.datetime "updated_at", null: false
87
86
  end
88
87
 
89
- create_table "apidae_towns", force: :cascade do |t|
90
- t.string "country"
91
- t.integer "apidae_id"
92
- t.string "insee_code"
93
- t.string "name"
94
- t.string "postal_code"
95
- t.datetime "created_at", null: false
96
- t.datetime "updated_at", null: false
88
+ create_table "apidae_selections", id: :serial, force: :cascade do |t|
89
+ t.string "label"
90
+ t.string "reference"
91
+ t.integer "apidae_id"
92
+ t.datetime "created_at", null: false
93
+ t.datetime "updated_at", null: false
97
94
  end
98
95
 
99
- add_index "apidae_towns", ["insee_code"], name: "index_apidae_towns_on_insee_code", unique: true, using: :btree
96
+ create_table "apidae_towns", id: :serial, force: :cascade do |t|
97
+ t.string "country"
98
+ t.integer "apidae_id"
99
+ t.string "insee_code"
100
+ t.string "name"
101
+ t.string "postal_code"
102
+ t.datetime "created_at", null: false
103
+ t.datetime "updated_at", null: false
104
+ t.index ["insee_code"], name: "index_apidae_towns_on_insee_code", unique: true
105
+ end
100
106
 
101
107
  end
@@ -188,3 +188,98 @@ WHERE c.contype = 'f'
188
188
  ORDER BY c.conname
189
189
  
190
190
  DEPRECATION WARNING: Defining a route where `to` is a controller without an action is deprecated. Please change `to: 'dashboard/index'` to `controller: 'dashboard/index'`. (called from block in <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/config/routes.rb:9)
191
+  (45.2ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
192
+  (2.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
193
+  (5.3ms) SELECT pg_try_advisory_lock(6140174353533887940)
194
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
195
+ Migrating to AddPicturesDataToObjects (20170513115401)
196
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
197
+  (0.4ms) SELECT pg_try_advisory_lock(6140174353533887940)
198
+  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
199
+ Migrating to CreateApidaeAttachedFiles (20170513121215)
200
+  (11.7ms) BEGIN
201
+  (24.3ms) CREATE TABLE "apidae_attached_files" ("id" serial NOT NULL PRIMARY KEY, "name" character varying, "credits" character varying, "description" text, "apidae_object_id" integer, "picture_file_name" character varying, "picture_content_type" character varying, "picture_file_size" integer, "picture_updated_at" timestamp, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
202
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20170513121215"]]
203
+  (0.6ms) COMMIT
204
+ Migrating to RenameObjectsSelectionsTable (20170513205932)
205
+  (6.0ms) BEGIN
206
+  (18.8ms) ALTER TABLE "apidae_objects_apidae_selections" RENAME TO "apidae_objects_selections"
207
+  (0.4ms) ALTER TABLE "public"."apidae_objects_apidae_selections_id_seq" RENAME TO "apidae_objects_selections_id_seq"
208
+  (0.3ms) ALTER INDEX "apidae_objects_apidae_selections_pkey" RENAME TO "apidae_objects_selections_pkey"
209
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20170513205932"]]
210
+  (0.4ms) COMMIT
211
+ Migrating to AddEntityDataToObjects (20170720161134)
212
+  (0.2ms) BEGIN
213
+  (10.3ms) ALTER TABLE "apidae_objects" ADD "entity_data" text
214
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20170720161134"]]
215
+  (6.3ms) COMMIT
216
+ Migrating to CreateApidaeFileImports (20170730102424)
217
+  (0.2ms) BEGIN
218
+  (21.6ms) CREATE TABLE "apidae_file_imports" ("id" serial NOT NULL PRIMARY KEY, "status" character varying, "remote_file" character varying, "created" integer, "updated" integer, "deleted" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
219
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20170730102424"]]
220
+  (0.6ms) COMMIT
221
+ Migrating to CreateApidaeExports (20171025075304)
222
+  (6.2ms) BEGIN
223
+  (15.7ms) CREATE TABLE "apidae_exports" ("id" serial NOT NULL PRIMARY KEY, "status" character varying, "remote_status" character varying, "oneshot" boolean, "reset" boolean, "file_url" character varying, "confirm_url" character varying, "project_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
224
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20171025075304"]]
225
+  (0.5ms) COMMIT
226
+ Migrating to CreateApidaeSelectionObjects (20180217222410)
227
+  (6.3ms) BEGIN
228
+  (8.9ms) CREATE TABLE "apidae_selection_objects" ("id" bigserial primary key, "apidae_selection_id" integer, "apidae_object_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
229
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180217222410"]]
230
+  (6.0ms) COMMIT
231
+ Migrating to AddIndexToApidaeTowns (20180218094339)
232
+  (0.4ms) BEGIN
233
+  (0.2ms) ROLLBACK
234
+  (0.3ms) SELECT pg_advisory_unlock(6140174353533887940)
235
+  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
236
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
237
+ Migrating to ChangeTextColumnsToJson (20180218172704)
238
+  (0.1ms) BEGIN
239
+  (0.8ms) ALTER TABLE "apidae_objects" ALTER COLUMN "pictures_data" TYPE jsonb USING CAST(value AS JSON)
240
+  (0.1ms) ROLLBACK
241
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
242
+  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
243
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
244
+ Migrating to ChangeTextColumnsToJson (20180218172704)
245
+  (0.2ms) BEGIN
246
+  (0.7ms) ALTER TABLE "apidae_objects" ALTER COLUMN "pictures_data" TYPE jsonb USING CAST(pictures_data AS JSON)
247
+  (0.1ms) ROLLBACK
248
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
249
+  (0.1ms) SELECT pg_try_advisory_lock(6140174353533887940)
250
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
251
+ Migrating to ChangeTextColumnsToJson (20180218172704)
252
+  (0.2ms) BEGIN
253
+  (0.8ms) ALTER TABLE "apidae_objects" ALTER COLUMN "pictures_data" TYPE jsonb USING pictures_data::JSON
254
+  (0.1ms) ROLLBACK
255
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
256
+  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
257
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
258
+ Migrating to ChangeTextColumnsToJson (20180218172704)
259
+  (0.2ms) BEGIN
260
+  (8.5ms) ALTER TABLE "apidae_objects" ALTER COLUMN "pictures_data" TYPE jsonb USING pictures_data::text::jsonb
261
+  (2.4ms) ALTER TABLE "apidae_objects" ALTER COLUMN "type_data" TYPE jsonb USING type_data::text::jsonb
262
+  (4.0ms) ALTER TABLE "apidae_objects" ALTER COLUMN "entity_data" TYPE jsonb USING entity_data::text::jsonb
263
+  (2.8ms) ALTER TABLE "apidae_objects" ALTER COLUMN "contact" TYPE jsonb USING contact::text::jsonb
264
+  (2.9ms) ALTER TABLE "apidae_objects" ALTER COLUMN "address" TYPE jsonb USING address::text::jsonb
265
+  (3.1ms) ALTER TABLE "apidae_objects" ALTER COLUMN "openings" TYPE jsonb USING openings::text::jsonb
266
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180218172704"]]
267
+  (3.6ms) COMMIT
268
+ ActiveRecord::InternalMetadata Load (0.7ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
269
+  (0.2ms) BEGIN
270
+ SQL (0.4ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2018-02-18 17:35:13.592426"], ["updated_at", "2018-02-18 17:35:13.592426"]]
271
+  (0.3ms) COMMIT
272
+  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
273
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
274
+  (0.3ms) SELECT pg_try_advisory_lock(6140174353533887940)
275
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
276
+ Migrating to AddServiceDataToApidaeObjects (20180218231319)
277
+  (0.2ms) BEGIN
278
+  (0.9ms) ALTER TABLE "apidae_objects" ADD "service_data" jsonb
279
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20180218231319"]]
280
+  (5.5ms) COMMIT
281
+ ActiveRecord::InternalMetadata Load (7.7ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
282
+  (0.2ms) BEGIN
283
+  (0.1ms) COMMIT
284
+  (0.3ms) SELECT pg_advisory_unlock(6140174353533887940)
285
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ selection_id: 1
5
+ object_id: 1
6
+
7
+ two:
8
+ selection_id: 1
9
+ object_id: 1
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module Apidae
4
+ class SelectionObjectTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apidae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-10 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -89,11 +89,13 @@ files:
89
89
  - app/helpers/apidae/import_helper.rb
90
90
  - app/helpers/apidae/objects_helper.rb
91
91
  - app/helpers/apidae/selections_helper.rb
92
+ - app/models/apidae/application_record.rb
92
93
  - app/models/apidae/attached_file.rb
93
94
  - app/models/apidae/export.rb
94
95
  - app/models/apidae/file_import.rb
95
96
  - app/models/apidae/object.rb
96
97
  - app/models/apidae/selection.rb
98
+ - app/models/apidae/selection_object.rb
97
99
  - app/models/apidae/town.rb
98
100
  - app/views/apidae/dashboard/index.html.erb
99
101
  - app/views/apidae/import/callback.html.erb
@@ -120,6 +122,9 @@ files:
120
122
  - db/migrate/20170720161134_add_entity_data_to_objects.rb
121
123
  - db/migrate/20170730102424_create_apidae_file_imports.rb
122
124
  - db/migrate/20171025075304_create_apidae_exports.rb
125
+ - db/migrate/20180217222410_create_apidae_selection_objects.rb
126
+ - db/migrate/20180218172704_change_text_columns_to_json.rb
127
+ - db/migrate/20180218231319_add_service_data_to_apidae_objects.rb
123
128
  - lib/apidae.rb
124
129
  - lib/apidae/engine.rb
125
130
  - lib/apidae/version.rb
@@ -176,6 +181,7 @@ files:
176
181
  - test/fixtures/apidae/attached_files.yml
177
182
  - test/fixtures/apidae/exports.yml
178
183
  - test/fixtures/apidae/objects.yml
184
+ - test/fixtures/apidae/selection_objects.yml
179
185
  - test/fixtures/apidae/selections.yml
180
186
  - test/fixtures/apidae/towns.yml
181
187
  - test/integration/navigation_test.rb
@@ -183,6 +189,7 @@ files:
183
189
  - test/models/apidae/export_test.rb
184
190
  - test/models/apidae/file_import_test.rb
185
191
  - test/models/apidae/object_test.rb
192
+ - test/models/apidae/selection_object_test.rb
186
193
  - test/models/apidae/selection_test.rb
187
194
  - test/models/apidae/town_test.rb
188
195
  - test/test_helper.rb
@@ -206,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
213
  version: '0'
207
214
  requirements: []
208
215
  rubyforge_project:
209
- rubygems_version: 2.6.13
216
+ rubygems_version: 2.5.1
210
217
  signing_key:
211
218
  specification_version: 4
212
219
  summary: A Ruby on Rails engine for projects that involve Apidae data
@@ -251,11 +258,13 @@ test_files:
251
258
  - test/dummy/README.rdoc
252
259
  - test/integration/navigation_test.rb
253
260
  - test/models/apidae/object_test.rb
261
+ - test/models/apidae/selection_object_test.rb
254
262
  - test/models/apidae/selection_test.rb
255
263
  - test/models/apidae/file_import_test.rb
256
264
  - test/models/apidae/export_test.rb
257
265
  - test/models/apidae/attached_file_test.rb
258
266
  - test/models/apidae/town_test.rb
267
+ - test/fixtures/apidae/selection_objects.yml
259
268
  - test/fixtures/apidae/towns.yml
260
269
  - test/fixtures/apidae/objects.yml
261
270
  - test/fixtures/apidae/selections.yml