apidae 1.3.3 → 1.3.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d1f8d7ad0798847cc0b3882958e5f557f1f01219
4
- data.tar.gz: 94d139b245115c273ec4c73b385c380bf816da87
2
+ SHA256:
3
+ metadata.gz: 75dde9650200cc683aac33972e62266dd313530eb14fdf1adce960666b055752
4
+ data.tar.gz: 210f1dcc7a842812d00fb4ea471b33c2f00327b4ae32bb1727dc831e878df263
5
5
  SHA512:
6
- metadata.gz: 47dea0045600b59233e78a4616396aee8341de70e9121a335741fbe66d39ffea03e18503564a83c4cd9fe496ebe7058b7ba13690c902f794f46967146d65b16d
7
- data.tar.gz: 2350154e37a3fac1d56eed268eb322309842fcf8b349c2e2b28c63af4605aa3cb15c1b629f31a60d740ffe6ec6b9778e9c2a9ae4f03414ae9c86a3023661c719
6
+ metadata.gz: f1e8f20bd1163222ad25c737b2d4593159c774f15afe9d10143317540de6fb4cab3f66f09bab4155e41e7459b7728e3bb64ba39f46600011fd1bc7daac561eaa
7
+ data.tar.gz: 44ca9a17ccd7d50fe8bf878158902f623e007162027abc923293dbbf3ee96e0fde3b41809f1d93b8e33f8000ff85acc68d40d3c1c4c9025db2bcf093caabb815
@@ -113,7 +113,7 @@ module Apidae
113
113
  short_desc: node_value(data_hash, :descriptifCourt, *locales),
114
114
  long_desc: node_value(data_hash, :descriptifDetaille, *locales),
115
115
  theme_desc: data_hash[:descriptifsThematises].blank? ? {} : Hash[data_hash[:descriptifsThematises].map {|th| [node_id(th, :theme), node_value(th, :description, *locales)]}],
116
- private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], node_value(d, :descriptif, *locales)]}]
116
+ private_desc: private_data.blank? ? {} : Hash[private_data.map {|d| [d[:nomTechnique], (node_value(d, :descriptif, *locales).blank? ? {LOCALE_FR => d[:libelleFr]} : node_value(d, :descriptif, *locales))]}]
117
117
  }
118
118
  end
119
119
  end
@@ -151,6 +151,7 @@ module Apidae
151
151
  name: localized_value(att, :nom, locale),
152
152
  url: att[:traductionFichiers][0][:url].gsub('http:', 'https:'),
153
153
  type: att[:type],
154
+ link: att[:link],
154
155
  description: localized_value(att, :legende, locale)
155
156
  }
156
157
  end
@@ -222,6 +223,8 @@ module Apidae
222
223
  loc_data[:latitude] = geoloc_details[:geoJson][:coordinates][1]
223
224
  loc_data[:longitude] = geoloc_details[:geoJson][:coordinates][0]
224
225
  end
226
+ loc_data[:map_reference] = geoloc_details[:reperePlan]
227
+ loc_data[:altitude] = geoloc_details[:altitude] if geoloc_details
225
228
  loc_data[:access] = node_value(geoloc_details, :complement) if geoloc_details
226
229
  loc_data[:environments] = location_hash[:environnements].map {|e| e[:id]} if location_hash[:environnements]
227
230
  end
@@ -236,6 +239,7 @@ module Apidae
236
239
  openings_desc: node_value(openings_hash, :periodeEnClair, *locales),
237
240
  openings_desc_mode: openings_hash[:periodeEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
238
241
  openings: build_openings(openings_hash, *locales),
242
+ all_year_long: openings_hash[:ouvertTouteLAnnee] == 'OUVERT_TOUTE_L_ANNEE' ? 'true' : 'false',
239
243
  time_periods: lists_ids(openings_hash[:indicationsPeriode]),
240
244
  openings_extra: lists_ids(openings_hash[:ouverturesComplementaires])
241
245
  }
@@ -249,6 +253,7 @@ module Apidae
249
253
  methods = rates_hash[:modesPaiement].blank? ? [] : rates_hash[:modesPaiement].map {|p| p[:id]}
250
254
  {
251
255
  rates_desc: desc, rates: values, payment_methods: methods,
256
+ tax_included: rates_hash[:taxeDeSejourIncluse].blank? ? nil : (rates_hash[:taxeDeSejourIncluse] == 'OUI'),
252
257
  rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
253
258
  includes: node_value(rates_hash, :leTarifComprend, *locales),
254
259
  excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
@@ -264,18 +269,21 @@ module Apidae
264
269
  apidae_obj.apidae_subtype = node_id(data_hash, :rubrique) if apidae_obj.apidae_type == Obj::EQU
265
270
  apidae_obj.apidae_subtype = lists_ids(data_hash[:typesHebergement]).first if apidae_obj.apidae_type == Obj::SPA
266
271
  {
267
- categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles], data_hash[:activiteCategories]),
272
+ categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles], data_hash[:activiteCategories], data_hash[:typesHabitation]),
268
273
  themes: lists_ids(data_hash[:themes]),
269
274
  capacity: (data_hash[:capacite] || {})
270
275
  .merge(presta_hash ? {group_min: presta_hash[:tailleGroupeMin], group_max: presta_hash[:tailleGroupeMax],
271
276
  age_min: presta_hash[:ageMin], age_max: presta_hash[:ageMax]} : {}),
272
277
  classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral], data_hash[:classification]) +
273
278
  lists_ids(data_hash[:classementsGuides]) + lists_ids(data_hash[:classements]),
279
+ classification_date: data_hash[:dateClassement],
280
+ classification_ref: data_hash[:numeroClassement],
274
281
  labels: lists_ids(data_hash[:labels], data_hash[:labelsChartesQualite], prestations_hash[:labelsTourismeHandicap]) +
275
282
  (node_id(data_hash, :typeLabel) ? [node_id(data_hash, :typeLabel)] : []),
276
283
  chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
277
284
  area: apidae_obj.apidae_type == Obj::DOS ? data_hash.except(:classification) : node_value(data_hash, :lieuDePratique),
278
- track: apidae_obj.apidae_type == Obj::EQU ? data_hash[:itineraire] : nil,
285
+ track: apidae_obj.apidae_type == Obj::EQU ? (data_hash[:itineraire] || {}).except(:passagesDelicats) : nil,
286
+ tricky_sections: apidae_obj.apidae_type == Obj::EQU ? node_value(data_hash[:itineraire], :passagesDelicats, *locales) : nil,
279
287
  products: lists_ids(data_hash[:typesProduit], data_hash[:aopAocIgps], data_hash[:specialites]),
280
288
  audience: lists_ids(prestations_hash[:typesClientele]),
281
289
  animals: {allowed: prestations_hash[:animauxAcceptes] == 'ACCEPTES', desc: node_value(prestations_hash, :descriptifAnimauxAcceptes, *locales),
@@ -283,7 +291,10 @@ module Apidae
283
291
  extra: apidae_obj.apidae_type == Obj::SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
284
292
  duration: apidae_obj.apidae_type == Obj::SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
285
293
  certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
286
- business: business_hash
294
+ business: (business_hash || {}).except(:sallesEquipeesPour, :sallesEquipement, :sallesRestauration, :sallesReunion, :sallesHebergement),
295
+ business_equipments: lists_ids((business_hash || {})[:sallesEquipeesPour], (business_hash || {})[:sallesEquipement],
296
+ (business_hash || {})[:sallesRestauration], (business_hash || {})[:sallesHebergement]),
297
+ business_rooms: (business_hash || {})[:sallesReunion]
287
298
  }
288
299
  end
289
300
 
@@ -317,13 +328,19 @@ module Apidae
317
328
  tags
318
329
  end
319
330
 
320
- def self.parse_booking(reservation_hash, *locales)
331
+ def self.parse_booking(reservation_hash, visits_hash, *locales)
332
+ booking_hash = {}
321
333
  if reservation_hash
322
- {
323
- booking_desc: node_value(reservation_hash, :complement, *locales),
324
- booking_entities: reservation_hash[:organismes]
325
- }
334
+ booking_hash[:booking_desc] = node_value(reservation_hash, :complement, *locales),
335
+ booking_hash[:booking_entities] = reservation_hash[:organismes]
336
+ end
337
+ if visits_hash
338
+ booking_hash[:visits_allowed] = visits_hash[:visitable] == true
339
+ booking_hash[:visits_desc] = node_value(visits_hash, :complementVisite, *locales)
340
+ booking_hash[:visits_duration] = visits_hash[:dureeMoyenneVisiteIndividuelle]
341
+ booking_hash[:visits_services] = lists_ids(visits_hash[:prestationsVisitesGroupees]) + lists_ids(visits_hash[:prestationsVisitesIndividuelles])
326
342
  end
343
+ booking_hash
327
344
  end
328
345
 
329
346
  def self.parse_town(location_hash)
@@ -337,8 +354,14 @@ module Apidae
337
354
 
338
355
  def self.parse_entity_fields(information_hash, type_data_hash, sp_hash)
339
356
  entity_hash = {}
340
- if information_hash && information_hash[:structureGestion]
341
- entity_hash.merge!({entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)})
357
+ if information_hash
358
+ if information_hash[:structureGestion]
359
+ entity_hash.merge!({entity_id: information_hash[:structureGestion][:id], service_provider_id: node_id(type_data_hash, :prestataireActivites)})
360
+ end
361
+
362
+ if information_hash[:informationsLegales]
363
+ entity_hash.merge!({legal: information_hash[:informationsLegales]})
364
+ end
342
365
  end
343
366
  if sp_hash && sp_hash[:prestataireActivites]
344
367
  entity_hash[:is_service_provider] = true
@@ -30,18 +30,21 @@ module Apidae
30
30
  Town.import(zfile.read(TOWNS_FILE))
31
31
  logger.info "Completed #{Town.count} towns update"
32
32
  end
33
- zfile.each do |file|
33
+ ordered_files(zfile).each do |file|
34
34
  if file.file? && file.name.end_with?('.json')
35
35
  logger.info "Processing file : #{file.name}"
36
36
  if file.name.include?(MODIFIED_DIR)
37
37
  add_or_update_objects(zfile.read(file.name), result, project.locales, project.versions)
38
- elsif file.name.include?(DELETED_FILE)
39
- delete_objects(zfile.read(file.name), result)
40
- elsif file.name.include?(SELECTIONS_FILE)
38
+ end
39
+ if file.name.include?(SELECTIONS_FILE)
41
40
  add_or_update_selections(project, zfile.read(file.name), result)
42
41
  end
42
+ if file.name.include?(DELETED_FILE)
43
+ delete_objects(zfile.read(file.name), result)
44
+ end
43
45
  end
44
46
  end
47
+ project.cleanup_selections
45
48
  create(result.except(:selections)
46
49
  .merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
47
50
  logger.info "Import results : #{result}"
@@ -104,12 +107,16 @@ module Apidae
104
107
  end
105
108
  end
106
109
 
110
+ def self.ordered_files(zfile)
111
+ zfile.sort_by {|f| f.name.include?(MODIFIED_DIR) ? 0 : (f.name.include?(SELECTIONS_FILE) ? 1 : 2)}
112
+ end
113
+
107
114
  def self.delete_objects(deleted_json, result)
108
115
  deleted_ids = JSON.parse(deleted_json)
109
116
  deleted_ids.each do |id|
110
117
  obj = Obj.find_by_apidae_id(id)
111
118
  if obj
112
- obj.destroy!
119
+ obj.destroy! if obj.selections.empty?
113
120
  result[:deleted] += 1
114
121
  else
115
122
  logger.info "skipping object deletion : #{id}"
@@ -163,7 +170,9 @@ module Apidae
163
170
  def self.add_or_update_selections(project, selections_json, result)
164
171
  selections_hashes = JSON.parse(selections_json, symbolize_names: true)
165
172
  deleted_ids = Selection.where(apidae_project_id: project.id).collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
166
- Selection.where(apidae_id: deleted_ids).delete_all
173
+ apidae_selection_ids = Selection.where(apidae_id: deleted_ids).map {|s| s.id}
174
+ SelectionObject.where(apidae_selection_id: apidae_selection_ids).delete_all
175
+ Selection.where(id: apidae_selection_ids).delete_all
167
176
  selections_hashes.each do |selection_data|
168
177
  logger.info "Updating selection #{selection_data[:id]}"
169
178
  Selection.add_or_update(selection_data, project.id)
@@ -7,22 +7,24 @@ module Apidae
7
7
 
8
8
  attr_accessor :locale
9
9
  attr_accessor :obj_version
10
+ attr_accessor :obj_versions
10
11
 
11
12
  store_accessor :title_data, :title
12
13
  store_accessor :owner_data, :owner_name, :owner_id
13
14
  store_accessor :description_data, :short_desc, :long_desc, :theme_desc, :private_desc
14
15
  store_accessor :pictures_data, :pictures
15
16
  store_accessor :attachments_data, :attachments
16
- store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track,
17
- :products, :audience, :animals, :animals_desc, :extra, :duration, :certifications, :business
18
- store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id, :is_service_provider
17
+ store_accessor :type_data, :categories, :themes, :capacity, :classification, :classification_date,
18
+ :classification_ref, :labels, :chains, :area, :track, :tricky_sections, :products, :audience, :animals,
19
+ :animals_desc, :extra, :duration, :certifications, :business, :business_equipments, :business_rooms
20
+ store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id, :is_service_provider, :legal
19
21
  store_accessor :contact_data, :telephone, :email, :website, :google, :facebook, :twitter, :yelp, :trip_advisor, :fax,
20
22
  :mobile_website, :shorty_url, :contacts
21
- store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments
23
+ store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments, :altitude, :map_reference
22
24
  store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
23
- store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra
25
+ store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_extra, :tax_included
24
26
  store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
25
- store_accessor :booking_data, :booking_desc, :booking_entities
27
+ store_accessor :booking_data, :booking_desc, :booking_entities, :visits_allowed, :visits_desc, :visits_duration, :visits_services
26
28
  store_accessor :tags_data, :promo, :internal, :linked
27
29
  store_accessor :version_data, :versioned_fields
28
30
 
@@ -83,7 +85,7 @@ module Apidae
83
85
  COS => {node: :informationsCommerceEtService, subtype: :commerceEtServiceType},
84
86
  DEG => {node: :informationsDegustation, subtype: :degustationType},
85
87
  DOS => {node: :informationsDomaineSkiable, subtype: :domaineSkiableType},
86
- EQU => {node: :informationsEquipement, subtype: :equipementType},
88
+ EQU => {node: :informationsEquipement, subtype: :rubrique},
87
89
  FEM => {node: :informationsFeteEtManifestation, subtype: :feteEtManifestationType},
88
90
  HCO => {node: :informationsHebergementCollectif, subtype: :hebergementCollectifType},
89
91
  HLO => {node: :informationsHebergementLocatif, subtype: :hebergementLocatifType},
@@ -100,6 +102,7 @@ module Apidae
100
102
  after_initialize do
101
103
  @locale = DEFAULT_LOCALE
102
104
  @obj_version = DEFAULT_VERSION
105
+ @obj_versions = {}
103
106
  end
104
107
 
105
108
  def root_obj
@@ -111,11 +114,15 @@ module Apidae
111
114
  end
112
115
 
113
116
  def in_version(v)
114
- @cached_versions ||= {}
115
- if @cached_versions[v].nil?
116
- @cached_versions[v] = versions.where(version: v).first
117
+ if v == DEFAULT_VERSION && root_obj_id.nil?
118
+ @obj_version = DEFAULT_VERSION
119
+ self
120
+ else
121
+ if @obj_versions[v].nil?
122
+ @obj_versions[v] = versions.where(version: v).first
123
+ end
124
+ @obj_versions[v]
117
125
  end
118
- @cached_versions[v]
119
126
  end
120
127
 
121
128
  def in_locale(l)
@@ -164,6 +171,7 @@ module Apidae
164
171
  apidae_obj
165
172
  end
166
173
 
174
+ # Note : overrides existing fields (not a merge)
167
175
  def self.populate_fields(apidae_obj, object_data, locales)
168
176
  type_fields = TYPES_DATA[object_data[:type]]
169
177
  apidae_obj.last_update = DateTime.parse(object_data[:gestion][:dateModification]) unless object_data[:gestion].blank?
@@ -178,7 +186,7 @@ module Apidae
178
186
  apidae_obj.town = ApidaeDataParser.parse_town(object_data[:localisation])
179
187
  apidae_obj.openings_data = ApidaeDataParser.parse_openings(object_data[:ouverture], *locales)
180
188
  apidae_obj.rates_data = ApidaeDataParser.parse_rates(object_data[:descriptionTarif], *locales)
181
- apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], *locales)
189
+ apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], object_data[:visites], *locales)
182
190
  apidae_obj.type_data = ApidaeDataParser.parse_type_data(apidae_obj, object_data[type_fields[:node]], object_data[:prestations],
183
191
  object_data[:tourismeAffaires], *locales)
184
192
  apidae_obj.pictures_data = ApidaeDataParser.parse_pictures_data(object_data[:illustrations], *locales)
@@ -20,5 +20,11 @@ module Apidae
20
20
  def versions=(values)
21
21
  self.versions_data = values.blank? ? nil : values.join('|')
22
22
  end
23
+
24
+ def cleanup_selections
25
+ apidae_selections.reload.each do |s|
26
+ s.cleanup
27
+ end
28
+ end
23
29
  end
24
30
  end
@@ -42,6 +42,20 @@ module Apidae
42
42
  SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
43
43
  end
44
44
 
45
+ def cleanup
46
+ obsolete_count = apidae_selection_objects
47
+ .joins("LEFT JOIN apidae_objs ON apidae_objs.id = apidae_selection_objects.apidae_object_id")
48
+ .where("apidae_objs.id IS NULL")
49
+ .delete_all
50
+ logger.info "Cleaned up #{obsolete_count} obsolete selection-objects associations for selection #{apidae_id}"
51
+
52
+ dups = apidae_selection_objects.reload.group(:apidae_object_id)
53
+ .select("COUNT(id), apidae_object_id, ARRAY_AGG(id) AS so_ids")
54
+ .having("COUNT(id) > ?", 1).map {|so| so.so_ids}
55
+ dups_count = apidae_selection_objects.where(id: dups.map {|d| d.sort[1..-1]}.flatten).delete_all
56
+ logger.info "Cleaned up #{dups_count} duplicate selection-objects associations for selection #{apidae_id}"
57
+ end
58
+
45
59
  def results(where_clause, offset, size)
46
60
  objects.includes(:town).limit(size).offset(offset).where(where_clause)
47
61
  end
@@ -5,7 +5,7 @@ module Apidae
5
5
  territories_hashes.each do |t_data|
6
6
  t = Territory.find_or_initialize_by(apidae_id: t_data[:id])
7
7
  t.name = t_data.dig(:nom, :libelleFr)
8
-
8
+ t.apidae_type = t_data.dig(:territoireType, :id)
9
9
  t.save!
10
10
  end
11
11
  end
@@ -27,6 +27,9 @@ module Apidae
27
27
 
28
28
  LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments, :openings_desc, :rates_desc,
29
29
  :includes, :excludes, :extra, :booking_desc]
30
- ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website, :services,
31
- :equipments, :comfort, :activities, :promo, :internal, :linked]
30
+ ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website,
31
+ :google, :facebook, :twitter, :yelp, :trip_advisor, :fax, :mobile_website, :shorty_url,
32
+ :openings, :openings_extra, :rates, :services, :payment_methods, :categories, :themes,
33
+ :labels, :chains, :classification, :challenged, :environments, :languages, :products,
34
+ :animals, :equipments, :comfort, :activities, :promo, :internal, :linked]
32
35
  end
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.7"
3
3
  end
@@ -0,0 +1,15 @@
1
+ [
2
+ {
3
+ "id": 49063,
4
+ "libelle": {
5
+ "libelleFr": "Sélection 2"
6
+ },
7
+ "nom": "Sélection 2",
8
+ "objetsTouristiques": [
9
+ {
10
+ "type": "STRUCTURE",
11
+ "id": 503
12
+ }
13
+ ]
14
+ }
15
+ ]
@@ -0,0 +1 @@
1
+ //= link_tree ../images
@@ -2,15 +2,15 @@
2
2
  # of editing this file, please use the migrations feature of Active Record to
3
3
  # incrementally modify your database, and then regenerate this schema definition.
4
4
  #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2020_05_22_124205) do
13
+ ActiveRecord::Schema.define(version: 2021_06_07_214647) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -92,8 +92,10 @@ ActiveRecord::Schema.define(version: 2020_05_22_124205) do
92
92
  t.datetime "created_at", null: false
93
93
  t.datetime "updated_at", null: false
94
94
  t.jsonb "meta_data"
95
+ t.boolean "is_active"
95
96
  t.index ["apidae_id"], name: "index_apidae_references_on_apidae_id"
96
97
  t.index ["apidae_type"], name: "index_apidae_references_on_apidae_type"
98
+ t.index ["is_active"], name: "index_apidae_references_on_is_active"
97
99
  end
98
100
 
99
101
  create_table "apidae_selection_objects", force: :cascade do |t|
@@ -112,6 +114,13 @@ ActiveRecord::Schema.define(version: 2020_05_22_124205) do
112
114
  t.integer "apidae_project_id"
113
115
  end
114
116
 
117
+ create_table "apidae_territories", force: :cascade do |t|
118
+ t.integer "apidae_id"
119
+ t.string "name"
120
+ t.integer "apidae_type"
121
+ t.index ["apidae_id"], name: "index_apidae_territories_on_apidae_id"
122
+ end
123
+
115
124
  create_table "apidae_towns", id: :serial, force: :cascade do |t|
116
125
  t.string "country"
117
126
  t.integer "apidae_id"
@@ -1,69 +1,24 @@
1
- Apidae::Obj Load (1.5ms) SELECT "apidae_objs".* FROM "apidae_objs" ORDER BY "apidae_objs"."id" ASC LIMIT $1 [["LIMIT", 1]]
2
-  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
3
-  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
4
- Migrating to AddProjectIdToSelections (20181024072424)
5
-  (0.2ms) BEGIN
6
-  (39.2ms) ALTER TABLE "apidae_selections" ADD "apidae_project_id" integer
7
- ActiveRecord::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181024072424"]]
8
-  (0.8ms) COMMIT
9
- Migrating to CreateApidaeProjects (20181024072843)
10
-  (0.1ms) BEGIN
11
-  (56.9ms) CREATE TABLE "apidae_projects" ("id" bigserial primary key, "name" character varying, "apidae_id" integer, "api_key" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
12
- ActiveRecord::SchemaMigration Create (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181024072843"]]
13
-  (2.1ms) COMMIT
14
- Migrating to AddApidaeIdToApidaeFileImports (20190111162443)
15
-  (40.0ms) BEGIN
16
-  (0.6ms) ALTER TABLE "apidae_file_imports" ADD "apidae_id" integer
17
- ActiveRecord::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190111162443"]]
18
-  (0.6ms) COMMIT
19
- Migrating to UpgradeApidaeObjsTitleDataType (20190123142628)
20
-  (0.1ms) BEGIN
21
-  (0.4ms) ALTER TABLE "apidae_objs" ADD "title_data" jsonb
22
- Apidae::Obj Load (0.5ms) SELECT "apidae_objs".* FROM "apidae_objs"
23
-  (1.4ms) ALTER TABLE "apidae_objs" DROP COLUMN "title"
24
- ActiveRecord::SchemaMigration Create (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190123142628"]]
25
-  (0.4ms) COMMIT
26
- ActiveRecord::InternalMetadata Load (1.9ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
27
-  (0.2ms) BEGIN
28
-  (0.1ms) COMMIT
29
-  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
30
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
31
-  (0.3ms) SELECT pg_try_advisory_lock(6140174353533887940)
32
-  (3.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
33
- Migrating to AddBookingDataToApidaeObjs (20190123160046)
34
-  (0.2ms) BEGIN
35
-  (0.7ms) ALTER TABLE "apidae_objs" ADD "booking_data" jsonb
36
- Apidae::Obj Load (1.0ms) SELECT "apidae_objs".* FROM "apidae_objs"
37
-  (0.5ms) ALTER TABLE "apidae_objs" DROP COLUMN "reservation"
38
- ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190123160046"]]
39
-  (0.6ms) COMMIT
40
- 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]]
41
-  (0.2ms) BEGIN
42
-  (0.1ms) COMMIT
43
-  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
44
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
45
-  (4.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
46
-  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
47
-  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
48
- Migrating to AddLocalesDataToApidaeProjects (20190123214635)
49
-  (0.2ms) BEGIN
50
-  (3.2ms) ALTER TABLE "apidae_projects" ADD "locales_data" character varying
51
- ActiveRecord::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190123214635"]]
52
-  (0.5ms) COMMIT
53
- ActiveRecord::InternalMetadata Load (42.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
54
-  (0.2ms) BEGIN
55
-  (0.1ms) COMMIT
56
-  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
57
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
58
-  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
59
-  (0.2ms) SELECT pg_try_advisory_lock(6140174353533887940)
60
-  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
61
- ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
62
-  (0.2ms) BEGIN
63
-  (0.2ms) COMMIT
64
-  (0.2ms) SELECT pg_advisory_unlock(6140174353533887940)
65
-  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
66
- Apidae::Obj Load (26.8ms) SELECT apidae_id, COUNT(id) FROM "apidae_objs" WHERE "apidae_objs"."root_obj_id" IS NULL GROUP BY "apidae_objs"."apidae_id" HAVING (COUNT(id) > 1)
67
- Apidae::Obj Load (2.4ms) SELECT apidae_id, COUNT(id) FROM "apidae_objs" WHERE "apidae_objs"."root_obj_id" IS NULL GROUP BY "apidae_objs"."apidae_id" HAVING (COUNT(id) > 1)
68
- Apidae::Obj Load (0.8ms) SELECT "apidae_objs".* FROM "apidae_objs" ORDER BY "apidae_objs"."id" ASC LIMIT $1 [["LIMIT", 1]]
69
-  (3.4ms) SELECT COUNT(*) FROM "apidae_objs"
1
+ DEPRECATION WARNING: Initialization autoloaded the constants Apidae::ApidaeHelper, Apidae::ApplicationHelper, Apidae::ApiHelper, Apidae::DashboardHelper, Apidae::ExtendableHelper, Apidae::ImportHelper, Apidae::ObjectsHelper, Apidae::ReferencesHelper, Apidae::SelectionsHelper, and Apidae::ApplicationController.
2
+
3
+ Being able to do this is deprecated. Autoloading during initialization is going
4
+ to be an error condition in future versions of Rails.
5
+
6
+ Reloading does not reboot the application, and therefore code executed during
7
+ initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
8
+ the expected changes won't be reflected in that stale Module object.
9
+
10
+ `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
11
+
12
+ In order to autoload safely at boot time, please wrap your code in a reloader
13
+ callback this way:
14
+
15
+ Rails.application.reloader.to_prepare do
16
+ # Autoload classes and modules needed at boot time here.
17
+ end
18
+
19
+ That block runs when the application boots, and every time there is a reload.
20
+ For historical reasons, it may run twice, so it has to be idempotent.
21
+
22
+ Check the "Autoloading and Reloading Constants" guide to learn more about how
23
+ Rails autoloads and reloads.
24
+ (called from <top (required)> at /Users/jbvilain/workspace/apidae-engine-rails/test/dummy/config/environment.rb:5)
@@ -166,6 +166,29 @@ module Apidae
166
166
  assert_equal 0, Selection.count
167
167
  end
168
168
 
169
+ test "object deletion cancelled if used by another project" do
170
+ proj = Project.create(apidae_id: 123)
171
+ other_proj = Project.create(apidae_id: 456)
172
+ sel = Selection.create(apidae_id: 49063, apidae_project_id: proj.id, label: 'Sélection 2', reference: 'selection-2')
173
+ other_sel = Selection.create(apidae_id: 49999, apidae_project_id: other_proj.id, label: 'Sélection 99', reference: 'selection-99')
174
+ sel.objects << Obj.create(apidae_id: 503, title: 'Société des violoncellistes aixois')
175
+ sel.objects << Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
176
+ other_sel.objects << Obj.find_by_apidae_id(504)
177
+
178
+ assert_equal 2, sel.objects.count
179
+ assert_equal 1, other_sel.objects.count
180
+
181
+ selections_json = File.read('test/data/shared_selections.json')
182
+ FileImport.add_or_update_selections(proj, selections_json, @result)
183
+ deletion_json = File.read('test/data/deletion.json')
184
+ FileImport.delete_objects(deletion_json, @result)
185
+
186
+ assert_equal 2, Obj.count
187
+ assert_equal({created: 0, updated: 0, deleted: 1, selections:
188
+ [{:apidae_id=>49063, :reference=>"selection-2", :objects=>1}]}, @result)
189
+ assert_equal 1, other_sel.objects.count
190
+ end
191
+
169
192
  test "full import process" do
170
193
  Obj.create(apidae_id: 123, title: 'Objet à supprimer')
171
194
  Obj.create(apidae_id: 4826186, title: 'Objet à mettre à jour')
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: 1.3.3
4
+ version: 1.3.7
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: 2021-06-07 00:00:00.000000000 Z
11
+ date: 2022-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -209,10 +209,12 @@ files:
209
209
  - test/data/hot_fr_en.json
210
210
  - test/data/json_export.zip
211
211
  - test/data/selections.json
212
+ - test/data/shared_selections.json
212
213
  - test/data/structure.json
213
214
  - test/data/update_selections.json
214
215
  - test/dummy/README.rdoc
215
216
  - test/dummy/Rakefile
217
+ - test/dummy/app/assets/config/manifest.js
216
218
  - test/dummy/app/assets/javascripts/application.js
217
219
  - test/dummy/app/assets/stylesheets/application.css
218
220
  - test/dummy/app/controllers/application_controller.rb
@@ -245,7 +247,6 @@ files:
245
247
  - test/dummy/config/secrets.yml
246
248
  - test/dummy/db/schema.rb
247
249
  - test/dummy/log/development.log
248
- - test/dummy/log/test.log
249
250
  - test/dummy/public/404.html
250
251
  - test/dummy/public/422.html
251
252
  - test/dummy/public/500.html
@@ -284,14 +285,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
285
  - !ruby/object:Gem::Version
285
286
  version: '0'
286
287
  requirements: []
287
- rubyforge_project:
288
- rubygems_version: 2.6.13
288
+ rubygems_version: 3.1.6
289
289
  signing_key:
290
290
  specification_version: 4
291
291
  summary: A Ruby on Rails engine for projects that involve Apidae data
292
292
  test_files:
293
293
  - test/dummy/app/controllers/application_controller.rb
294
294
  - test/dummy/app/views/layouts/application.html.erb
295
+ - test/dummy/app/assets/config/manifest.js
295
296
  - test/dummy/app/assets/javascripts/application.js
296
297
  - test/dummy/app/assets/stylesheets/application.css
297
298
  - test/dummy/app/helpers/application_helper.rb
@@ -326,7 +327,6 @@ test_files:
326
327
  - test/dummy/public/500.html
327
328
  - test/dummy/public/404.html
328
329
  - test/dummy/db/schema.rb
329
- - test/dummy/log/test.log
330
330
  - test/dummy/log/development.log
331
331
  - test/dummy/README.rdoc
332
332
  - test/integration/navigation_test.rb
@@ -351,6 +351,7 @@ test_files:
351
351
  - test/controllers/apidae/dashboard_controller_test.rb
352
352
  - test/controllers/apidae/references_controller_test.rb
353
353
  - test/controllers/apidae/import_controller_test.rb
354
+ - test/data/shared_selections.json
354
355
  - test/data/equ_groups.json
355
356
  - test/data/update_selections.json
356
357
  - test/data/json_export.zip