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 +5 -5
- data/app/models/apidae/file_import.rb +6 -16
- data/app/models/apidae/obj.rb +14 -18
- data/app/models/apidae/project.rb +0 -6
- data/app/models/apidae/selection.rb +4 -19
- data/config/initializers/constants.rb +1 -2
- data/config/locales/apidae.fr.yml +0 -1
- data/lib/apidae/version.rb +1 -1
- data/test/dummy/log/development.log +65 -216
- data/test/models/apidae/file_import_test.rb +0 -23
- metadata +4 -7
- data/test/data/shared_selections.json +0 -15
- data/test/dummy/log/test.log +0 -754
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1e5d13058f65857b20c5eb5ebcb31933047d458d
|
4
|
+
data.tar.gz: 57c158bf11ea28f28c25094e2e2b732289cd1b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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!
|
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
|
-
|
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)
|
data/app/models/apidae/obj.rb
CHANGED
@@ -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
|
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
|
22
|
-
store_accessor :rates_data, :rates_desc, :rates_desc_mode, :rates, :payment_methods, :includes, :excludes
|
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
|
-
|
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]
|
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],
|
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
|
@@ -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
|
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:
|
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]
|
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 <
|
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
|
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'
|
data/lib/apidae/version.rb
CHANGED
@@ -1,216 +1,65 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
to
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
+
[1m[36mApidae::Obj Load (1.5ms)[0m [1m[34mSELECT "apidae_objs".* FROM "apidae_objs" ORDER BY "apidae_objs"."id" ASC LIMIT $1[0m [["LIMIT", 1]]
|
2
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
3
|
+
[1m[35m (1.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
4
|
+
Migrating to AddProjectIdToSelections (20181024072424)
|
5
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
6
|
+
[1m[35m (39.2ms)[0m [1m[35mALTER TABLE "apidae_selections" ADD "apidae_project_id" integer[0m
|
7
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181024072424"]]
|
8
|
+
[1m[35m (0.8ms)[0m [1m[35mCOMMIT[0m
|
9
|
+
Migrating to CreateApidaeProjects (20181024072843)
|
10
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
11
|
+
[1m[35m (56.9ms)[0m [1m[35mCREATE 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)[0m
|
12
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.2ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181024072843"]]
|
13
|
+
[1m[35m (2.1ms)[0m [1m[35mCOMMIT[0m
|
14
|
+
Migrating to AddApidaeIdToApidaeFileImports (20190111162443)
|
15
|
+
[1m[35m (40.0ms)[0m [1m[35mBEGIN[0m
|
16
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "apidae_file_imports" ADD "apidae_id" integer[0m
|
17
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190111162443"]]
|
18
|
+
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
19
|
+
Migrating to UpgradeApidaeObjsTitleDataType (20190123142628)
|
20
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
21
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "apidae_objs" ADD "title_data" jsonb[0m
|
22
|
+
[1m[36mApidae::Obj Load (0.5ms)[0m [1m[34mSELECT "apidae_objs".* FROM "apidae_objs"[0m
|
23
|
+
[1m[35m (1.4ms)[0m [1m[35mALTER TABLE "apidae_objs" DROP COLUMN "title"[0m
|
24
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.2ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190123142628"]]
|
25
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
26
|
+
[1m[36mActiveRecord::InternalMetadata Load (1.9ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
27
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
28
|
+
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
29
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
30
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
31
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
32
|
+
[1m[35m (3.6ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
33
|
+
Migrating to AddBookingDataToApidaeObjs (20190123160046)
|
34
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
35
|
+
[1m[35m (0.7ms)[0m [1m[35mALTER TABLE "apidae_objs" ADD "booking_data" jsonb[0m
|
36
|
+
[1m[36mApidae::Obj Load (1.0ms)[0m [1m[34mSELECT "apidae_objs".* FROM "apidae_objs"[0m
|
37
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "apidae_objs" DROP COLUMN "reservation"[0m
|
38
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190123160046"]]
|
39
|
+
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
40
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.7ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
41
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
42
|
+
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
43
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
44
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
45
|
+
[1m[35m (4.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
46
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
47
|
+
[1m[35m (0.6ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
48
|
+
Migrating to AddLocalesDataToApidaeProjects (20190123214635)
|
49
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
50
|
+
[1m[35m (3.2ms)[0m [1m[35mALTER TABLE "apidae_projects" ADD "locales_data" character varying[0m
|
51
|
+
[1m[36mActiveRecord::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190123214635"]]
|
52
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
53
|
+
[1m[36mActiveRecord::InternalMetadata Load (42.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
54
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
55
|
+
[1m[35m (0.1ms)[0m [1m[35mCOMMIT[0m
|
56
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
57
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
58
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
59
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_try_advisory_lock(6140174353533887940)[0m
|
60
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
61
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
62
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
63
|
+
[1m[35m (0.2ms)[0m [1m[35mCOMMIT[0m
|
64
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT pg_advisory_unlock(6140174353533887940)[0m
|
65
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
@@ -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')
|