apidae 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1f478ace8d9c21c1828378878eab8381ed9ee22
4
- data.tar.gz: d2b1c7a2eeff050037b44338aac920f9991f2ee9
3
+ metadata.gz: a89823d97fa0f65fa985b4c5868cdcad0ddc4c66
4
+ data.tar.gz: 3ea06983a6b4a0e36b5607dce58f5908048153f7
5
5
  SHA512:
6
- metadata.gz: 6edb0d4ee75349d2e913d8579d569ea1fe9b4c7b9fd76bcc1a52e47ab677a7c742160eef63b1249f7302590f14779df1428105397a580ce9383f66a49b0618f3
7
- data.tar.gz: bc82634c379de6056875538067bf0273f8ddf6bef4ec4b236913603fc35073e76da740e3ff38014d41ebcd3f2702574b33663caf8caebda32be3f041c28f025e
6
+ metadata.gz: 4682b5926be504889286583e6a316eb3a7940cccd9aaf91408944a165f33dc1134a1b84548e91e57a7825233784b9e4be4fa30792c66b086001ce64087f09bc3
7
+ data.tar.gz: 3812b82094ed52d53eb62a3ba6110fe7a97ef7a680434fd2109e2e072681e6cd090b5b024188e6436b9741da4b1c8806922dd9d5d08b429bb1a77ac36728a143
@@ -8,6 +8,7 @@ module Apidae
8
8
  STATUS_CANCELLED = 'cancelled'
9
9
 
10
10
  TOWNS_FILE = 'communes.json'
11
+ INTERNAL_FILE = 'criteres_internes.json'
11
12
  REFERENCES_FILE = 'elements_reference.json'
12
13
  MODIFIED_DIR = 'objets_modifies'
13
14
  DELETED_FILE = 'objets_supprimes.json'
@@ -17,6 +18,7 @@ module Apidae
17
18
  Zip::File.open(zip_file) do |zfile|
18
19
  result = {created: 0, updated: 0, deleted: 0, selections: []}
19
20
  Reference.import(zfile.read(REFERENCES_FILE))
21
+ Reference.import_internal(zfile.read(INTERNAL_FILE))
20
22
  logger.info "Completed #{Reference.count} references update"
21
23
  Town.import(zfile.read(TOWNS_FILE))
22
24
  logger.info "Completed #{Town.count} towns update"
@@ -183,8 +183,7 @@ module Apidae
183
183
  capacity: data_hash[:capacite],
184
184
  classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral]),
185
185
  labels: lists_ids(data_hash[:labels], prestations_hash[:labelsTourismeHandicap]),
186
- chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
187
- activities: lists_ids(data_hash[:activites])
186
+ chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel])
188
187
  }
189
188
  end
190
189
  end
@@ -195,7 +194,7 @@ module Apidae
195
194
  services: lists_ids(data_hash[:services]),
196
195
  equipments: lists_ids(data_hash[:equipements]),
197
196
  comfort: lists_ids(data_hash[:conforts]),
198
- activities: lists_ids(data_hash[:activites]) + lists_ids(data_hash[:activites])
197
+ activities: lists_ids(data_hash[:activites]) + lists_ids(type_data_hash[:activites])
199
198
  }
200
199
  end
201
200
  end
@@ -1,11 +1,13 @@
1
1
  module Apidae
2
2
  class Reference < ApplicationRecord
3
+
4
+ INTERNAL = 'internal'
5
+
3
6
  def self.import(refs_json)
4
7
  refs_hashes = JSON.parse(refs_json, symbolize_names: true)
5
- if refs_hashes.length != count
8
+ if refs_hashes.length != where("apidae_type != ?", INTERNAL).count
6
9
  refs_hashes.each do |ref_data|
7
- ref = Reference.find_or_initialize_by(apidae_id: ref_data[:id])
8
- ref.apidae_type = ref_data[:elementReferenceType]
10
+ ref = Reference.find_or_initialize_by(apidae_id: ref_data[:id], apidae_type: ref_data[:elementReferenceType])
9
11
  ref.label_data = ref_data.slice(:libelleFr, :libelleEn)
10
12
  ref.save!
11
13
  end
@@ -17,6 +19,17 @@ module Apidae
17
19
  import(refs_json)
18
20
  end
19
21
 
22
+ def self.import_internal(internal_json)
23
+ refs_hashes = JSON.parse(internal_json, symbolize_names: true)
24
+ if refs_hashes.length != where(apidae_type: INTERNAL).count
25
+ refs_hashes.each do |ref_data|
26
+ ref = Reference.find_or_initialize_by(apidae_id: ref_data[:id], apidae_type: INTERNAL)
27
+ ref.label_data = {libelleFr: ref_data[:libelle]}
28
+ ref.save!
29
+ end
30
+ end
31
+ end
32
+
20
33
  def label(language)
21
34
  label_data["libelle#{language.to_s.upcase_first}"]
22
35
  end
@@ -0,0 +1,6 @@
1
+ class RemoveApidaeIdUnicity < ActiveRecord::Migration[5.1]
2
+ def change
3
+ remove_index :apidae_references, :apidae_id
4
+ add_index :apidae_references, :apidae_id
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apidae
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain
@@ -136,6 +136,7 @@ files:
136
136
  - db/migrate/20180307170349_create_apidae_references.rb
137
137
  - db/migrate/20180314093512_add_tags_data_to_apidae_objects.rb
138
138
  - db/migrate/20180314132631_add_meta_data_to_apidae_objects.rb
139
+ - db/migrate/20180319143954_remove_apidae_id_unicity.rb
139
140
  - lib/apidae.rb
140
141
  - lib/apidae/engine.rb
141
142
  - lib/apidae/version.rb