apidae 0.9.34 → 0.10.0

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
- SHA256:
3
- metadata.gz: 19f4dc1ae011dc6f13e271bbbbff28eb59710068d444c21c8ac6bf4952f423b9
4
- data.tar.gz: 03d28c16f13a83a89918c5b8a790b9651975f68cb681c356c0e065a553b6eaed
2
+ SHA1:
3
+ metadata.gz: 1e5d13058f65857b20c5eb5ebcb31933047d458d
4
+ data.tar.gz: 57c158bf11ea28f28c25094e2e2b732289cd1b47
5
5
  SHA512:
6
- metadata.gz: 18eaa64392193791632314d650ace16fc3cb8f795b3c50b222ecdb76b50ce9501fd8cc2bca664cbbf6941359f0a2d9ac0a23c637d0cec20cab32ccc971bfca69
7
- data.tar.gz: 35ebab3b19a709f29e3d75e1abe93563395fa2fa3b50d8c8c93734290973b9ba3e8438f3977c4433d6a820ee6d0f87ef1c0fd7551a2d343b42dd71031d2d71b1
6
+ metadata.gz: '039e3d10fa484d795ad731c1a178b567f7c793b2a339ea835370f0a3c59318734ecb5bc9cd818073da9d4c16cdaf03d9d833f83c507d8589f39fe41d56c32657'
7
+ data.tar.gz: 188194787706a94cf7b04854bdd92266095ee95607b24a764ad2ccadda0fec50f076bb9d0631b7bb3454c02c80c74334bb5f313832d10ac012b86ec4ad3c3e23
@@ -30,22 +30,18 @@ module Apidae
30
30
  Town.import(zfile.read(TOWNS_FILE))
31
31
  logger.info "Completed #{Town.count} towns update"
32
32
  end
33
- ordered_files(zfile).each do |file|
34
- puts "processing #{file.name}"
33
+ zfile.each do |file|
35
34
  if file.file? && file.name.end_with?('.json')
36
35
  logger.info "Processing file : #{file.name}"
37
36
  if file.name.include?(MODIFIED_DIR)
38
37
  add_or_update_objects(zfile.read(file.name), result, project.locales, project.versions)
39
- end
40
- if file.name.include?(SELECTIONS_FILE)
41
- add_or_update_selections(project, zfile.read(file.name), result)
42
- end
43
- if file.name.include?(DELETED_FILE)
38
+ elsif file.name.include?(DELETED_FILE)
44
39
  delete_objects(zfile.read(file.name), result)
40
+ elsif file.name.include?(SELECTIONS_FILE)
41
+ add_or_update_selections(project, zfile.read(file.name), result)
45
42
  end
46
43
  end
47
44
  end
48
- project.cleanup_selections
49
45
  create(result.except(:selections)
50
46
  .merge({remote_file: (zip_file.is_a?(File) ? zip_file.path : zip_file), status: STATUS_COMPLETE, apidae_id: project_id}))
51
47
  logger.info "Import results : #{result}"
@@ -108,16 +104,12 @@ module Apidae
108
104
  end
109
105
  end
110
106
 
111
- def self.ordered_files(zfile)
112
- zfile.sort_by {|f| f.name.include?(MODIFIED_DIR) ? 0 : (f.name.include?(SELECTIONS_FILE) ? 1 : 2)}
113
- end
114
-
115
107
  def self.delete_objects(deleted_json, result)
116
108
  deleted_ids = JSON.parse(deleted_json)
117
109
  deleted_ids.each do |id|
118
110
  obj = Obj.find_by_apidae_id(id)
119
111
  if obj
120
- obj.destroy! if obj.selections.empty?
112
+ obj.destroy!
121
113
  result[:deleted] += 1
122
114
  else
123
115
  logger.info "skipping object deletion : #{id}"
@@ -171,9 +163,7 @@ module Apidae
171
163
  def self.add_or_update_selections(project, selections_json, result)
172
164
  selections_hashes = JSON.parse(selections_json, symbolize_names: true)
173
165
  deleted_ids = Selection.where(apidae_project_id: project.id).collect {|sel| sel.apidae_id}.uniq - selections_hashes.collect {|sel| sel[:id]}
174
- apidae_selection_ids = Selection.where(apidae_id: deleted_ids).map {|s| s.id}
175
- SelectionObject.where(apidae_selection_id: apidae_selection_ids).delete_all
176
- Selection.where(id: apidae_selection_ids).delete_all
166
+ Selection.where(apidae_id: deleted_ids).delete_all
177
167
  selections_hashes.each do |selection_data|
178
168
  logger.info "Updating selection #{selection_data[:id]}"
179
169
  Selection.add_or_update(selection_data, project.id)
@@ -14,12 +14,12 @@ module Apidae
14
14
  store_accessor :pictures_data, :pictures
15
15
  store_accessor :attachments_data, :attachments
16
16
  store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track,
17
- :products, :audience, :animals, :extra, :duration, :certifications, :business, :complement
17
+ :products, :audience, :animals, :extra, :duration, :certifications, :business
18
18
  store_accessor :entity_data, :entity_id, :entity_name, :service_provider_id
19
19
  store_accessor :contact, :telephone, :email, :website
20
20
  store_accessor :location_data, :address, :place, :latitude, :longitude, :access, :territories, :environments
21
- store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods, :openings_extra
22
- store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes, :rates_complement
21
+ store_accessor :openings_data, :openings_desc, :openings_desc_mode, :openings, :time_periods
22
+ store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes
23
23
  store_accessor :service_data, :services, :equipments, :comfort, :activities, :challenged, :languages
24
24
  store_accessor :booking_data, :booking_desc, :booking_entities
25
25
  store_accessor :tags_data, :promo, :internal, :linked
@@ -109,7 +109,11 @@ module Apidae
109
109
  end
110
110
 
111
111
  def in_version(v)
112
- versions.where(version: v).first
112
+ @cached_versions ||= {}
113
+ if @cached_versions[v].nil?
114
+ @cached_versions[v] = versions.where(version: v).first
115
+ end
116
+ @cached_versions[v]
113
117
  end
114
118
 
115
119
  def in_locale(l)
@@ -293,18 +297,12 @@ module Apidae
293
297
  when PHONE
294
298
  contact_details[:telephone] ||= []
295
299
  contact_details[:telephone] << c[:coordonnees][:fr]
296
- contact_details[:telephone_details] ||= []
297
- contact_details[:telephone_details] << {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
298
300
  when EMAIL
299
301
  contact_details[:email] ||= []
300
302
  contact_details[:email] << c[:coordonnees][:fr]
301
- contact_details[:email_details] ||= []
302
- contact_details[:email_details] << {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
303
303
  when WEBSITE
304
304
  contact_details[:website] ||= []
305
305
  contact_details[:website] << c[:coordonnees][:fr]
306
- contact_details[:website_details] ||= []
307
- contact_details[:website_details] << {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
308
306
  else
309
307
  end
310
308
  end
@@ -345,14 +343,14 @@ module Apidae
345
343
  end
346
344
  end
347
345
 
346
+ # Note : use internal format for openings storage (ideally Apihours one, to merge data from both sources)
348
347
  def self.parse_openings(openings_hash, *locales)
349
348
  if openings_hash && openings_hash[:periodeEnClair]
350
349
  {
351
350
  openings_desc: node_value(openings_hash, :periodeEnClair, *locales),
352
351
  openings_desc_mode: openings_hash[:periodeEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
353
352
  openings: openings_hash[:periodesOuvertures],
354
- time_periods: lists_ids(openings_hash[:indicationsPeriode]),
355
- openings_extra: lists_ids(openings_hash[:ouverturesComplementaires])
353
+ time_periods: lists_ids(openings_hash[:indicationsPeriode])
356
354
  }
357
355
  end
358
356
  end
@@ -366,8 +364,7 @@ module Apidae
366
364
  rates_desc: desc, rates: values, payment_methods: methods,
367
365
  rates_desc_mode: rates_hash[:tarifsEnClairGenerationMode] == 'AUTOMATIQUE' ? MODE_AUTO : MODE_MANUAL,
368
366
  includes: node_value(rates_hash, :leTarifComprend, *locales),
369
- excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales),
370
- rates_complement: node_value(rates_hash, :complement, *locales)
367
+ excludes: node_value(rates_hash, :leTarifNeComprendPas, *locales)
371
368
  }
372
369
  end
373
370
  end
@@ -397,8 +394,7 @@ module Apidae
397
394
  extra: apidae_obj.apidae_type == SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
398
395
  duration: apidae_obj.apidae_type == SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
399
396
  certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
400
- business: business_hash,
401
- complement: apidae_obj.apidae_type == SPA ? node_value(prestations_hash, :complementAccueil, *locales) : {},
397
+ business: business_hash
402
398
  }
403
399
  end
404
400
 
@@ -427,7 +423,7 @@ module Apidae
427
423
  end
428
424
  unless linked_data_hash.blank? || linked_data_hash[:liensObjetsTouristiquesTypes].blank?
429
425
  tags[:linked] = linked_data_hash[:liensObjetsTouristiquesTypes]
430
- .map {|l| {apidae_id: l[:objetTouristique][:id], apidae_type: l[:objetTouristique][:type], category: l[:type], name: l[:objetTouristique][:nom]}}
426
+ .map {|l| {apidae_id: l[:objetTouristique][:id], apidae_type: l[:objetTouristique][:type], category: l[:type]}}
431
427
  end
432
428
  tags
433
429
  end
@@ -461,7 +457,7 @@ module Apidae
461
457
 
462
458
  def self.build_rate(rate_period)
463
459
  {
464
- id: rate_period[:identifiant], from: rate_period[:dateDebut], to: rate_period[:dateFin],
460
+ id: rate_period[:identifiant], start_date: rate_period[:dateDebut], end_date: rate_period[:dateFin],
465
461
  values: rate_period[:tarifs].blank? ? [] : rate_period[:tarifs].map {|t| {min: t[:minimum], max: t[:maximum], type: t[:type][:id], details: node_value(t, :precisionTarif)}}
466
462
  }
467
463
  end
@@ -20,11 +20,5 @@ 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
29
23
  end
30
24
  end
@@ -42,20 +42,6 @@ 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
-
59
45
  def results(where_clause, offset, size)
60
46
  objects.includes(:town).limit(size).offset(offset).where(where_clause)
61
47
  end
@@ -79,7 +65,7 @@ module Apidae
79
65
  key = cache_key(:agenda, from, to)
80
66
  res = $apidae_cache.read(key)
81
67
  unless res
82
- query_args = build_args(AGENDA_ENDPOINT, {selection_ids: [apidae_id], from: from, to: to, count: 200})
68
+ query_args = build_args(AGENDA_ENDPOINT, {selection_ids: [apidae_id], from: from, to: to})
83
69
  res = query_api(query_args, true)
84
70
  $apidae_cache.write(key, res)
85
71
  end
@@ -130,7 +116,7 @@ module Apidae
130
116
  obj = Obj.update_object(obj, obj_data, apidae_project.locales, apidae_project.versions)
131
117
  else
132
118
  obj = Obj.add_object(obj_data, apidae_project.locales, apidae_project.versions)
133
- SelectionObject.create(apidae_selection_id: id, apidae_object_id: obj.id)
119
+ SelectionObject.create(apidae_selection_id: id, apidae_object_id: added_obj.id)
134
120
  end
135
121
  if Rails.application.config.respond_to?(:apidae_obj_refresh_callback)
136
122
  Rails.application.config.apidae_obj_refresh_callback.call(obj.apidae_id)
@@ -149,15 +135,14 @@ module Apidae
149
135
 
150
136
  if all_results
151
137
  loops = 0
152
- max_loops = only_ids ? 50 : MAX_LOOPS
153
138
  query_args[:first] = 0
154
- query_args[:count] ||= MAX_COUNT
139
+ query_args[:count] = MAX_COUNT
155
140
  query_args[:locales] ||= apidae_project && !apidae_project.locales.blank? ? apidae_project.locales : [DEFAULT_LOCALE]
156
141
  response = JSON.parse get_response(query_args), symbolize_names: false
157
142
  total = response['numFound']
158
143
  query_result[:results] = (only_ids ? response['objetTouristiqueIds'] : response['objetsTouristiques']) || {}
159
144
 
160
- while total > results_count(query_result) && loops < max_loops
145
+ while total > results_count(query_result) && loops < MAX_LOOPS
161
146
  loops += 1
162
147
  query_args[:first] += MAX_COUNT
163
148
  response = JSON.parse get_response(query_args), symbolize_names: false
@@ -8,10 +8,9 @@ module Apidae
8
8
  LOCALE_ZH = 'zh'
9
9
  LOCALE_ES = 'es'
10
10
  LOCALE_PT_BR = 'pt-BR'
11
- LOCALE_JP = 'jp'
12
11
 
13
12
  DEFAULT_LOCALE = LOCALE_FR
14
- ALL_LOCALES = [LOCALE_FR, LOCALE_EN, LOCALE_IT, LOCALE_DE, LOCALE_NL, LOCALE_RU, LOCALE_ZH, LOCALE_ES, LOCALE_PT_BR, LOCALE_JP]
13
+ ALL_LOCALES = [LOCALE_FR, LOCALE_EN, LOCALE_IT, LOCALE_DE, LOCALE_NL, LOCALE_RU, LOCALE_ZH, LOCALE_ES, LOCALE_PT_BR]
15
14
 
16
15
  STANDARD_VERSION = 'STANDARD'
17
16
  WINTER_VERSION = 'HIVER'
@@ -32,7 +32,6 @@ fr:
32
32
  ru: Russe
33
33
  zh: Chinois
34
34
  'pt-BR': Brésilien
35
- jp: Japonais
36
35
  versions:
37
36
  STANDARD: Standard
38
37
  HIVER: Hiver
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "0.9.34"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -1,216 +1,65 @@
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)
25
- 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.
26
-
27
- Being able to do this is deprecated. Autoloading during initialization is going
28
- to be an error condition in future versions of Rails.
29
-
30
- Reloading does not reboot the application, and therefore code executed during
31
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
32
- the expected changes won't be reflected in that stale Module object.
33
-
34
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
35
-
36
- In order to autoload safely at boot time, please wrap your code in a reloader
37
- callback this way:
38
-
39
- Rails.application.reloader.to_prepare do
40
- # Autoload classes and modules needed at boot time here.
41
- end
42
-
43
- That block runs when the application boots, and every time there is a reload.
44
- For historical reasons, it may run twice, so it has to be idempotent.
45
-
46
- Check the "Autoloading and Reloading Constants" guide to learn more about how
47
- Rails autoloads and reloads.
48
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
49
- 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.
50
-
51
- Being able to do this is deprecated. Autoloading during initialization is going
52
- to be an error condition in future versions of Rails.
53
-
54
- Reloading does not reboot the application, and therefore code executed during
55
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
56
- the expected changes won't be reflected in that stale Module object.
57
-
58
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
59
-
60
- In order to autoload safely at boot time, please wrap your code in a reloader
61
- callback this way:
62
-
63
- Rails.application.reloader.to_prepare do
64
- # Autoload classes and modules needed at boot time here.
65
- end
66
-
67
- That block runs when the application boots, and every time there is a reload.
68
- For historical reasons, it may run twice, so it has to be idempotent.
69
-
70
- Check the "Autoloading and Reloading Constants" guide to learn more about how
71
- Rails autoloads and reloads.
72
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
73
- 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.
74
-
75
- Being able to do this is deprecated. Autoloading during initialization is going
76
- to be an error condition in future versions of Rails.
77
-
78
- Reloading does not reboot the application, and therefore code executed during
79
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
80
- the expected changes won't be reflected in that stale Module object.
81
-
82
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
83
-
84
- In order to autoload safely at boot time, please wrap your code in a reloader
85
- callback this way:
86
-
87
- Rails.application.reloader.to_prepare do
88
- # Autoload classes and modules needed at boot time here.
89
- end
90
-
91
- That block runs when the application boots, and every time there is a reload.
92
- For historical reasons, it may run twice, so it has to be idempotent.
93
-
94
- Check the "Autoloading and Reloading Constants" guide to learn more about how
95
- Rails autoloads and reloads.
96
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
97
- 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.
98
-
99
- Being able to do this is deprecated. Autoloading during initialization is going
100
- to be an error condition in future versions of Rails.
101
-
102
- Reloading does not reboot the application, and therefore code executed during
103
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
104
- the expected changes won't be reflected in that stale Module object.
105
-
106
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
107
-
108
- In order to autoload safely at boot time, please wrap your code in a reloader
109
- callback this way:
110
-
111
- Rails.application.reloader.to_prepare do
112
- # Autoload classes and modules needed at boot time here.
113
- end
114
-
115
- That block runs when the application boots, and every time there is a reload.
116
- For historical reasons, it may run twice, so it has to be idempotent.
117
-
118
- Check the "Autoloading and Reloading Constants" guide to learn more about how
119
- Rails autoloads and reloads.
120
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
121
- 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.
122
-
123
- Being able to do this is deprecated. Autoloading during initialization is going
124
- to be an error condition in future versions of Rails.
125
-
126
- Reloading does not reboot the application, and therefore code executed during
127
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
128
- the expected changes won't be reflected in that stale Module object.
129
-
130
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
131
-
132
- In order to autoload safely at boot time, please wrap your code in a reloader
133
- callback this way:
134
-
135
- Rails.application.reloader.to_prepare do
136
- # Autoload classes and modules needed at boot time here.
137
- end
138
-
139
- That block runs when the application boots, and every time there is a reload.
140
- For historical reasons, it may run twice, so it has to be idempotent.
141
-
142
- Check the "Autoloading and Reloading Constants" guide to learn more about how
143
- Rails autoloads and reloads.
144
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
145
- 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.
146
-
147
- Being able to do this is deprecated. Autoloading during initialization is going
148
- to be an error condition in future versions of Rails.
149
-
150
- Reloading does not reboot the application, and therefore code executed during
151
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
152
- the expected changes won't be reflected in that stale Module object.
153
-
154
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
155
-
156
- In order to autoload safely at boot time, please wrap your code in a reloader
157
- callback this way:
158
-
159
- Rails.application.reloader.to_prepare do
160
- # Autoload classes and modules needed at boot time here.
161
- end
162
-
163
- That block runs when the application boots, and every time there is a reload.
164
- For historical reasons, it may run twice, so it has to be idempotent.
165
-
166
- Check the "Autoloading and Reloading Constants" guide to learn more about how
167
- Rails autoloads and reloads.
168
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
169
- 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.
170
-
171
- Being able to do this is deprecated. Autoloading during initialization is going
172
- to be an error condition in future versions of Rails.
173
-
174
- Reloading does not reboot the application, and therefore code executed during
175
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
176
- the expected changes won't be reflected in that stale Module object.
177
-
178
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
179
-
180
- In order to autoload safely at boot time, please wrap your code in a reloader
181
- callback this way:
182
-
183
- Rails.application.reloader.to_prepare do
184
- # Autoload classes and modules needed at boot time here.
185
- end
186
-
187
- That block runs when the application boots, and every time there is a reload.
188
- For historical reasons, it may run twice, so it has to be idempotent.
189
-
190
- Check the "Autoloading and Reloading Constants" guide to learn more about how
191
- Rails autoloads and reloads.
192
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
193
- 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.
194
-
195
- Being able to do this is deprecated. Autoloading during initialization is going
196
- to be an error condition in future versions of Rails.
197
-
198
- Reloading does not reboot the application, and therefore code executed during
199
- initialization does not run again. So, if you reload Apidae::ApidaeHelper, for example,
200
- the expected changes won't be reflected in that stale Module object.
201
-
202
- `config.autoloader` is set to `classic`. These autoloaded constants would have been unloaded if `config.autoloader` had been set to `:zeitwerk`.
203
-
204
- In order to autoload safely at boot time, please wrap your code in a reloader
205
- callback this way:
206
-
207
- Rails.application.reloader.to_prepare do
208
- # Autoload classes and modules needed at boot time here.
209
- end
210
-
211
- That block runs when the application boots, and every time there is a reload.
212
- For historical reasons, it may run twice, so it has to be idempotent.
213
-
214
- Check the "Autoloading and Reloading Constants" guide to learn more about how
215
- Rails autoloads and reloads.
216
- (called from <top (required)> at /Users/jbvilain/workspace/code/apidae-engine-rails/test/dummy/config/environment.rb:5)
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
@@ -153,29 +153,6 @@ module Apidae
153
153
  assert_equal 0, Selection.count
154
154
  end
155
155
 
156
- test "object deletion cancelled if used by another project" do
157
- proj = Project.create(apidae_id: 123)
158
- other_proj = Project.create(apidae_id: 456)
159
- sel = Selection.create(apidae_id: 49063, apidae_project_id: proj.id, label: 'Sélection 2', reference: 'selection-2')
160
- other_sel = Selection.create(apidae_id: 49999, apidae_project_id: other_proj.id, label: 'Sélection 99', reference: 'selection-99')
161
- sel.objects << Obj.create(apidae_id: 503, title: 'Société des violoncellistes aixois')
162
- sel.objects << Obj.create(apidae_id: 504, title: 'Société des contrebassistes aixois')
163
- other_sel.objects << Obj.find_by_apidae_id(504)
164
-
165
- assert_equal 2, sel.objects.count
166
- assert_equal 1, other_sel.objects.count
167
-
168
- selections_json = File.read('test/data/shared_selections.json')
169
- FileImport.add_or_update_selections(proj, selections_json, @result)
170
- deletion_json = File.read('test/data/deletion.json')
171
- FileImport.delete_objects(deletion_json, @result)
172
-
173
- assert_equal 2, Obj.count
174
- assert_equal({created: 0, updated: 0, deleted: 1, selections:
175
- [{:apidae_id=>49063, :reference=>"selection-2", :objects=>1}]}, @result)
176
- assert_equal 1, other_sel.objects.count
177
- end
178
-
179
156
  test "full import process" do
180
157
  Obj.create(apidae_id: 123, title: 'Objet à supprimer')
181
158
  Obj.create(apidae_id: 4826186, title: 'Objet à mettre à jour')