apidae 1.4.26 → 2.0.0
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 +4 -4
- data/app/controllers/apidae/objects_controller.rb +7 -0
- data/app/controllers/apidae/projects_controller.rb +1 -7
- data/app/models/apidae/apidae_data_parser.rb +5 -16
- data/app/models/apidae/obj.rb +28 -2
- data/app/models/apidae/selection.rb +0 -4
- data/app/views/apidae/objects/search.html.erb +49 -0
- data/config/initializers/constants.rb +3 -3
- data/config/initializers/search.rb +23 -0
- data/config/locales/apidae.fr.yml +1 -1
- data/config/routes.rb +2 -4
- data/db/migrate/20250129190137_create_pg_search_documents.rb +17 -0
- data/db/migrate/20250130110941_add_columns_to_pg_search_documents.rb +10 -0
- data/db/migrate/20250130120941_add_tsv_column_to_pg_search_documents.rb +22 -0
- data/db/migrate/20250130152441_add_gin_index_to_pg_search_documents.rb +7 -0
- data/lib/apidae/version.rb +1 -1
- data/test/dummy/bin/rails +3 -3
- data/test/dummy/bin/rake +2 -2
- data/test/dummy/bin/setup +21 -13
- data/test/dummy/config/application.rb +21 -13
- data/test/dummy/config/boot.rb +2 -4
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +53 -19
- data/test/dummy/config/environments/production.rb +56 -36
- data/test/dummy/config/environments/test.rb +44 -19
- data/test/dummy/config/initializers/apidae.rb +7 -5
- data/test/dummy/config/initializers/content_security_policy.rb +25 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -2
- data/test/dummy/config/initializers/inflections.rb +4 -4
- data/test/dummy/config/initializers/new_framework_defaults_7_2.rb +70 -0
- data/test/dummy/config/initializers/permissions_policy.rb +13 -0
- data/test/dummy/config/puma.rb +34 -0
- data/test/dummy/config/storage.yml +34 -0
- data/test/dummy/db/migrate/20250129172254_add_service_name_to_active_storage_blobs.active_storage.rb +22 -0
- data/test/dummy/db/migrate/20250129172255_create_active_storage_variant_records.active_storage.rb +27 -0
- data/test/dummy/db/migrate/20250129172256_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb +8 -0
- data/test/dummy/log/development.log +0 -1358
- data/test/dummy/public/404.html +6 -6
- data/test/dummy/public/406-unsupported-browser.html +66 -0
- data/test/dummy/public/422.html +6 -6
- data/test/dummy/public/500.html +6 -6
- data/test/dummy/public/icon.png +0 -0
- data/test/dummy/public/icon.svg +3 -0
- data/test/dummy/public/robots.txt +1 -0
- metadata +105 -66
- data/db/migrate/20250323201235_change_objs_certifications_structure.rb +0 -15
- data/test/dummy/app/assets/config/manifest.js +0 -1
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/config/initializers/assets.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d2e758f9b9ec206503bf49f0b007a703e4b99d0092294b0f28dd563bfd7e0d3c
|
|
4
|
+
data.tar.gz: 6504e5a2b17c7fb7ac75ce662b8f9273d932ada2219be41d557a461be6b3aca2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a9348ceed64ae7dfa7476e4a444eff649cca4148b5329305e9057e8fcbbae396308cf8e99119b1cbe0518935e254b7471ab0234250215454014ed23c3022325
|
|
7
|
+
data.tar.gz: f0e3ee4e7945eec4fbb642a5838d29b81fb4c9a6ed34272b781180c30394d79b5f5ab3dc9910b25f0a79061b4058fb5364a50f2ae3a9327e883cc8cd89002d75
|
|
@@ -78,6 +78,13 @@ module Apidae
|
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
+
def search
|
|
82
|
+
user_selections = Project.where(apidae_id: apidae_user.apidae_projects_ids).map {|p| p.apidae_selection_ids}.flatten.uniq
|
|
83
|
+
@results = PgSearch::Document.tsv_search(params[:query])
|
|
84
|
+
.joins("INNER JOIN apidae_selection_objects AS aso ON (aso.apidae_object_id = pg_search_documents.searchable_id) AND pg_search_documents.searchable_type = 'Apidae::Obj'")
|
|
85
|
+
.where("aso.apidae_selection_id IN (?)", user_selections)
|
|
86
|
+
end
|
|
87
|
+
|
|
81
88
|
private
|
|
82
89
|
def set_object
|
|
83
90
|
@obj = Obj.find(params[:id])
|
|
@@ -3,9 +3,7 @@ require_dependency "apidae/application_controller"
|
|
|
3
3
|
module Apidae
|
|
4
4
|
class ProjectsController < ApplicationController
|
|
5
5
|
before_action :set_project, only: [:edit, :update, :destroy]
|
|
6
|
-
skip_before_action :check_user_data!, only: [:create
|
|
7
|
-
skip_before_action :verify_authenticity_token, only: [:realtime]
|
|
8
|
-
skip_before_action Rails.application.config.apidae_auth, only: [:realtime]
|
|
6
|
+
skip_before_action :check_user_data!, only: [:create]
|
|
9
7
|
|
|
10
8
|
def index
|
|
11
9
|
if user_is_admin?
|
|
@@ -49,10 +47,6 @@ module Apidae
|
|
|
49
47
|
redirect_to request.referrer, notice: 'Le projet a bien été supprimé.'
|
|
50
48
|
end
|
|
51
49
|
|
|
52
|
-
def realtime
|
|
53
|
-
Rails.logger.info "realtime webhook : #{params.to_unsafe_h}"
|
|
54
|
-
end
|
|
55
|
-
|
|
56
50
|
private
|
|
57
51
|
|
|
58
52
|
def set_project
|
|
@@ -141,7 +141,6 @@ module Apidae
|
|
|
141
141
|
description: localized_value(pic, :legende, locale),
|
|
142
142
|
credits: localized_value(pic, :copyright, locale),
|
|
143
143
|
expiration_date: pic[:dateLimiteDePublication] || '',
|
|
144
|
-
remote_file_name: pic_file[:fileName] || '',
|
|
145
144
|
properties: {size: pic_file[:taille], width: pic_file[:largeur], height: pic_file[:hauteur]}
|
|
146
145
|
}
|
|
147
146
|
end
|
|
@@ -179,21 +178,13 @@ module Apidae
|
|
|
179
178
|
case c[:type][:id]
|
|
180
179
|
when PHONE, ALT_PHONE
|
|
181
180
|
contact_details[:telephone] ||= {}
|
|
182
|
-
contact_details[:telephone][c[:identifiant]] = {
|
|
183
|
-
value: c.dig(:coordonnees, :fr),
|
|
184
|
-
description: c.dig(:observation, :libelleFr),
|
|
185
|
-
locales: Hash[(c[:coordonnees] || {}).except(:fr).keys.map {|l| [l, {value: c.dig(:coordonnees, l), description: c.dig(:observation, localized_key(l.to_s))}]}]
|
|
186
|
-
}
|
|
181
|
+
contact_details[:telephone][c[:identifiant]] = {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
|
|
187
182
|
else
|
|
188
183
|
contacts_refs_by_code = CONTACTS_MAP.invert
|
|
189
184
|
if contacts_refs_by_code.keys.include?(c[:type][:id])
|
|
190
185
|
contact_ref = contacts_refs_by_code[c[:type][:id]].to_sym
|
|
191
186
|
contact_details[contact_ref] ||= {}
|
|
192
|
-
contact_details[contact_ref][c[:identifiant]] = {
|
|
193
|
-
value: c.dig(:coordonnees, :fr),
|
|
194
|
-
description: c.dig(:observation, :libelleFr),
|
|
195
|
-
locales: Hash[(c[:coordonnees] || {}).except(:fr).keys.map {|l| [l, {value: c.dig(:coordonnees, l), description: c.dig(:observation, localized_key(l.to_s))}]}]
|
|
196
|
-
}
|
|
187
|
+
contact_details[contact_ref][c[:identifiant]] = {value: c[:coordonnees][:fr], description: c.dig(:observation, :libelleFr)}
|
|
197
188
|
end
|
|
198
189
|
end
|
|
199
190
|
end
|
|
@@ -259,7 +250,7 @@ module Apidae
|
|
|
259
250
|
end
|
|
260
251
|
end
|
|
261
252
|
|
|
262
|
-
def self.parse_type_data(apidae_obj, type_hash, presta_hash, business_hash,
|
|
253
|
+
def self.parse_type_data(apidae_obj, type_hash, presta_hash, business_hash, *locales)
|
|
263
254
|
data_hash = type_hash || {}
|
|
264
255
|
prestations_hash = presta_hash || {}
|
|
265
256
|
apidae_obj.apidae_subtype = lists_ids(data_hash[:typesManifestation]).first if apidae_obj.apidae_type == Obj::FEM
|
|
@@ -279,7 +270,6 @@ module Apidae
|
|
|
279
270
|
labels: lists_ids(data_hash[:labels], data_hash[:labelsChartesQualite], prestations_hash[:labelsTourismeHandicap]) +
|
|
280
271
|
(node_id(data_hash, :typeLabel) ? [node_id(data_hash, :typeLabel)] : []),
|
|
281
272
|
chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
|
|
282
|
-
ratings: (ratings_list || []).map {|r| {id: r[:id], type: r.dig(:nom, :id), rating: r.dig(:qualification, :id), ref: r[:numero], start_date: r[:dateDebutValidite], end_date: r[:dateFinValidite], last_visit: r[:dateDerniereVisite]}},
|
|
283
273
|
area: apidae_obj.apidae_type == Obj::DOS ? data_hash.except(:classification) : node_value(data_hash, :lieuDePratique),
|
|
284
274
|
track: apidae_obj.apidae_type == Obj::EQU ? (data_hash[:itineraire] || {}).except(:passagesDelicats) : nil,
|
|
285
275
|
tricky_sections: apidae_obj.apidae_type == Obj::EQU ? node_value(data_hash[:itineraire], :passagesDelicats, *locales) : nil,
|
|
@@ -289,7 +279,7 @@ module Apidae
|
|
|
289
279
|
desc: node_value(prestations_hash, :descriptifAnimauxAcceptes, *locales), fee: prestations_hash[:animauxAcceptesSupplement] == 'AVEC_SUPPLEMENT'},
|
|
290
280
|
extra: apidae_obj.apidae_type == Obj::SPA ? node_value(data_hash, :formuleHebergement, *locales) : node_value(prestations_hash, :complementAccueil, *locales),
|
|
291
281
|
duration: apidae_obj.apidae_type == Obj::SPA ? {days: data_hash[:nombreJours], nights: data_hash[:nombreNuits]} : data_hash[:dureeSeance],
|
|
292
|
-
certifications: data_hash[:agrements].blank? ?
|
|
282
|
+
certifications: data_hash[:agrements].blank? ? [] : data_hash[:agrements].map {|a| {id: a[:type][:id], identifier: a[:numero]}},
|
|
293
283
|
business: (business_hash || {}).except(:sallesEquipeesPour, :sallesEquipement, :sallesRestauration, :sallesReunion, :sallesHebergement),
|
|
294
284
|
business_equipments: lists_ids((business_hash || {})[:sallesEquipeesPour], (business_hash || {})[:sallesEquipement],
|
|
295
285
|
(business_hash || {})[:sallesRestauration], (business_hash || {})[:sallesHebergement]),
|
|
@@ -363,8 +353,7 @@ module Apidae
|
|
|
363
353
|
end
|
|
364
354
|
|
|
365
355
|
if information_hash[:informationsLegales]
|
|
366
|
-
entity_hash
|
|
367
|
-
entity_hash[:legal].merge!(information_hash[:informationsLegales])
|
|
356
|
+
entity_hash.merge!({legal: information_hash[:informationsLegales]})
|
|
368
357
|
end
|
|
369
358
|
end
|
|
370
359
|
if sp_hash && sp_hash[:prestataireActivites]
|
data/app/models/apidae/obj.rb
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
require 'pg_search'
|
|
2
|
+
|
|
1
3
|
module Apidae
|
|
2
4
|
class Obj < ActiveRecord::Base
|
|
5
|
+
include PgSearch::Model
|
|
6
|
+
multisearchable against: [:title, :short_desc, :town_search, :criteria_search],
|
|
7
|
+
additional_attributes: -> (o) { { searchable_fields: o.searchable_fields } }
|
|
3
8
|
|
|
4
9
|
belongs_to :town, class_name: 'Apidae::Town', foreign_key: :town_insee_code, primary_key: :insee_code, optional: true
|
|
5
10
|
has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_object_id
|
|
@@ -15,7 +20,7 @@ module Apidae
|
|
|
15
20
|
store_accessor :description_data, :short_desc, :long_desc, :theme_desc, :private_desc, :accessibility_desc
|
|
16
21
|
store_accessor :pictures_data, :pictures
|
|
17
22
|
store_accessor :attachments_data, :attachments
|
|
18
|
-
store_accessor :type_data, :categories, :themes, :capacity, :classification, :classification_date,
|
|
23
|
+
store_accessor :type_data, :categories, :themes, :capacity, :classification, :classification_date,
|
|
19
24
|
:classification_ref, :labels, :chains, :area, :track, :tricky_sections, :products, :audience, :animals,
|
|
20
25
|
:animals_desc, :extra, :duration, :certifications, :business, :business_equipments, :business_rooms
|
|
21
26
|
store_accessor :entity_data, :entity_id, :entity_name, :info_entity_id, :info_entity_name, :service_provider_id,
|
|
@@ -139,6 +144,27 @@ module Apidae
|
|
|
139
144
|
self
|
|
140
145
|
end
|
|
141
146
|
|
|
147
|
+
def town_search
|
|
148
|
+
town&.label
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def criteria_search
|
|
152
|
+
([SUBTYPES.dig(apidae_subtype&.to_i, :label)] + ref_search(payment_methods, PAYMENT) +
|
|
153
|
+
ref_search(categories, CATEGORIES) + ref_search(themes, THEMES) + ref_search(labels, LABELS) +
|
|
154
|
+
ref_search(chains, CHAINS) + ref_search(classification, CLASSIFICATION) + ref_search(services, SERVICES) +
|
|
155
|
+
ref_search(equipments, EQUIPMENTS) + ref_search(comfort, COMFORT) + ref_search(activities, ACTIVITIES) +
|
|
156
|
+
ref_search(challenged, CHALLENGED) + ref_search(audience, AUDIENCE) + ref_search(promo, PROMO) +
|
|
157
|
+
ref_search(environments, ENVIRONMENTS) + ref_search(products, PRODUCTS) + ref_search(internal, INTERNALS)).compact.uniq
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def ref_search(ref_values, ref_list, label_key = :label)
|
|
161
|
+
(ref_values || []).map {|r| ref_list.dig(r, label_key)}
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def searchable_fields
|
|
165
|
+
{s_title: title, s_desc: short_desc, s_external_id: apidae_id, s_type: apidae_type, s_picture: main_picture}
|
|
166
|
+
end
|
|
167
|
+
|
|
142
168
|
def dig(*keys)
|
|
143
169
|
root_key, *nested_keys = keys
|
|
144
170
|
root_val = self.send(root_key)
|
|
@@ -246,7 +272,7 @@ module Apidae
|
|
|
246
272
|
apidae_obj.rates_data = ApidaeDataParser.parse_rates(object_data[:descriptionTarif], *locales)
|
|
247
273
|
apidae_obj.booking_data = ApidaeDataParser.parse_booking(object_data[:reservation], object_data[:visites], *locales)
|
|
248
274
|
apidae_obj.type_data = ApidaeDataParser.parse_type_data(apidae_obj, object_data[type_fields[:node]], object_data[:prestations],
|
|
249
|
-
object_data[:tourismeAffaires],
|
|
275
|
+
object_data[:tourismeAffaires], *locales)
|
|
250
276
|
apidae_obj.pictures_data = ApidaeDataParser.parse_pictures_data(object_data[:illustrations], *locales)
|
|
251
277
|
apidae_obj.attachments_data = ApidaeDataParser.parse_attachments_data(object_data[:multimedias], *locales)
|
|
252
278
|
apidae_obj.entity_data = ApidaeDataParser.parse_entity_fields(object_data[:informations], object_data[type_fields[:node]], object_data[:informationsPrestataireActivites])
|
|
@@ -40,9 +40,6 @@ module Apidae
|
|
|
40
40
|
|
|
41
41
|
removed_ids = Obj.where(apidae_id: removed).map {|o| o.id}
|
|
42
42
|
SelectionObject.where(apidae_selection_id: apidae_sel.id, apidae_object_id: removed_ids).delete_all
|
|
43
|
-
if added.any? || removed.any? || (apidae_sel.objects.any? && apidae_sel.objects.maximum(:updated_at) > apidae_sel.updated_at)
|
|
44
|
-
apidae_sel.touch
|
|
45
|
-
end
|
|
46
43
|
end
|
|
47
44
|
|
|
48
45
|
def cleanup
|
|
@@ -264,7 +261,6 @@ module Apidae
|
|
|
264
261
|
first: opts[:first] || 0,
|
|
265
262
|
count: opts[:count] || MAX_COUNT,
|
|
266
263
|
selectionIds: opts[:selection_ids],
|
|
267
|
-
locales: opts[:locales] || (apidae_project&.locales.blank? ? [DEFAULT_LOCALE] : apidae_project.locales),
|
|
268
264
|
identifiants: opts[:obj_ids],
|
|
269
265
|
dateDebut: opts[:from],
|
|
270
266
|
dateFin: opts[:to],
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<%= render layout: "/layouts/#{Rails.application.config.apidae_layout}" do |styles| %>
|
|
2
|
+
<div id="apidae_header" class="<%= styles[:header] %>">
|
|
3
|
+
<%= link_to 'Importer un objet', apidae.new_object_path(selection_apidae_id: nil), class: styles[:objects] %>
|
|
4
|
+
<%= link_to 'Retour', root_path, class: styles[:back] %>
|
|
5
|
+
<h1 class="<%= styles[:h1] %>">Apidae - Rechercher des objets</h1>
|
|
6
|
+
</div>
|
|
7
|
+
<div id="apidae_dashboard" class="<%= styles[:wrapper] %>">
|
|
8
|
+
<div id="apidae_search_form" class="<%= styles[:body] %>">
|
|
9
|
+
<%= form_tag(apidae.search_objects_path, method: :get) do %>
|
|
10
|
+
<%= text_field_tag 'query', @query, placeholder: 'Recherche par mots-clés' %>
|
|
11
|
+
<%= submit_tag 'Rechercher' %>
|
|
12
|
+
<% end %>
|
|
13
|
+
<br/>
|
|
14
|
+
</div>
|
|
15
|
+
<div id="apidae_imports_panel" class="<%= styles[:body] %>">
|
|
16
|
+
<table id="apidae_objects" class="<%= styles[:table] %>">
|
|
17
|
+
<thead class="<%= styles[:table_head] %>">
|
|
18
|
+
<tr>
|
|
19
|
+
<th>Titre</th>
|
|
20
|
+
<th>Identifiant</th>
|
|
21
|
+
<th>Type</th>
|
|
22
|
+
<th>Mise à jour</th>
|
|
23
|
+
<th></th>
|
|
24
|
+
</tr>
|
|
25
|
+
</thead>
|
|
26
|
+
<tbody class="<%= styles[:table_body] %>">
|
|
27
|
+
<% @results.each do |object| %>
|
|
28
|
+
<tr>
|
|
29
|
+
<td><%= object.searchable_title %></td>
|
|
30
|
+
<td><%= object.searchable_id %></td>
|
|
31
|
+
<td><%= object.searchable_category %></td>
|
|
32
|
+
<td><%= object.updated_at.strftime('Le %d/%m/%Y à %H:%M') if object.updated_at %></td>
|
|
33
|
+
<td><%= link_to 'Rafraîchir', apidae.refresh_object_path(object), method: :post,
|
|
34
|
+
data: {confirm: 'Voulez-vous vraiment rafraîchir cet objet ? Les données existantes seront écrasées.'} %></td>
|
|
35
|
+
</tr>
|
|
36
|
+
<% end %>
|
|
37
|
+
<% if @results.empty? %>
|
|
38
|
+
<tr>
|
|
39
|
+
<td colspan="5">Aucun objet importé pour le moment.</td>
|
|
40
|
+
</tr>
|
|
41
|
+
<% end %>
|
|
42
|
+
</tbody>
|
|
43
|
+
</table>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<% end %>
|
|
47
|
+
<script>
|
|
48
|
+
|
|
49
|
+
</script>
|
|
@@ -25,10 +25,10 @@ module Apidae
|
|
|
25
25
|
ALL_VERSIONS = [STANDARD_VERSION, WINTER_VERSION, SUMMER_VERSION, CHALLENGED_VERSION, BUSINESS_VERSION,
|
|
26
26
|
GROUPS_VERSION, ACTIVITIES_VERSION]
|
|
27
27
|
|
|
28
|
-
LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments,
|
|
28
|
+
LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments, :accessibility_desc,
|
|
29
29
|
:openings_desc, :rates_desc, :includes, :excludes, :extra, :booking_desc]
|
|
30
|
-
|
|
31
|
-
ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :
|
|
30
|
+
# Todo : finish implem of localized accessibility fields
|
|
31
|
+
ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website,
|
|
32
32
|
:google, :facebook, :twitter, :yelp, :trip_advisor, :fax, :mobile_website, :shorty_url, :instagram,
|
|
33
33
|
:openings, :openings_extra, :rates, :services, :payment_methods, :categories, :themes,
|
|
34
34
|
:labels, :chains, :classification, :challenged, :environments, :languages, :products,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Rails.application.config.after_initialize do
|
|
2
|
+
require 'pg_search'
|
|
3
|
+
|
|
4
|
+
PgSearch.multisearch_options = {
|
|
5
|
+
using: {tsearch: {dictionary: 'fr'}},
|
|
6
|
+
ignoring: :accents
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
PgSearch::Document.pg_search_scope(:tsv_search, lambda { |*args|
|
|
10
|
+
{
|
|
11
|
+
query: args.first,
|
|
12
|
+
against: [:content],
|
|
13
|
+
ignoring: :accents,
|
|
14
|
+
using: {
|
|
15
|
+
tsearch: {
|
|
16
|
+
dictionary: 'fr',
|
|
17
|
+
prefix: true,
|
|
18
|
+
tsvector_column: ["tsv_content"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
end
|
|
@@ -64,6 +64,6 @@ fr:
|
|
|
64
64
|
PATRIMOINE_CULTUREL: Patrimoine culturel
|
|
65
65
|
PATRIMOINE_NATUREL: Patrimoine naturel
|
|
66
66
|
RESTAURATION: Restauration
|
|
67
|
-
SEJOUR_PACKAGE:
|
|
67
|
+
SEJOUR_PACKAGE: Séjour et produits packagés
|
|
68
68
|
STRUCTURE: Entité juridique
|
|
69
69
|
TERRITOIRE: Territoire
|
data/config/routes.rb
CHANGED
|
@@ -2,6 +2,7 @@ Apidae::Engine.routes.draw do
|
|
|
2
2
|
|
|
3
3
|
resources :objects, only: [:index, :show, :new, :create], path: 'objets' do
|
|
4
4
|
post 'refresh', on: :member
|
|
5
|
+
get 'search', on: :collection
|
|
5
6
|
end
|
|
6
7
|
|
|
7
8
|
resources :selections, only: [:index] do
|
|
@@ -11,10 +12,7 @@ Apidae::Engine.routes.draw do
|
|
|
11
12
|
end
|
|
12
13
|
end
|
|
13
14
|
resources :references, only: [:index]
|
|
14
|
-
resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], path: 'projets'
|
|
15
|
-
post 'realtime', on: :collection
|
|
16
|
-
end
|
|
17
|
-
|
|
15
|
+
resources :projects, only: [:index, :new, :create, :edit, :update, :destroy], path: 'projets'
|
|
18
16
|
|
|
19
17
|
match 'import/callback', via: :post, to: 'import#callback'
|
|
20
18
|
match 'import/run', via: :post, to: 'import#run'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class CreatePgSearchDocuments < ActiveRecord::Migration[7.2]
|
|
2
|
+
def up
|
|
3
|
+
say_with_time("Creating table for pg_search multisearch") do
|
|
4
|
+
create_table :pg_search_documents do |t|
|
|
5
|
+
t.text :content
|
|
6
|
+
t.belongs_to :searchable, polymorphic: true, index: true
|
|
7
|
+
t.timestamps null: false
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def down
|
|
13
|
+
say_with_time("Dropping table for pg_search multisearch") do
|
|
14
|
+
drop_table :pg_search_documents
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class AddColumnsToPgSearchDocuments < ActiveRecord::Migration[7.2]
|
|
2
|
+
def up
|
|
3
|
+
# extra attributes columns
|
|
4
|
+
add_column :pg_search_documents, :searchable_fields, :jsonb
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def down
|
|
8
|
+
remove_column :pg_search_documents, :searchable_fields, if_exists: true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class AddTsvColumnToPgSearchDocuments < ActiveRecord::Migration[7.2]
|
|
2
|
+
def up
|
|
3
|
+
execute <<-SQL
|
|
4
|
+
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
|
|
5
|
+
ALTER TEXT SEARCH CONFIGURATION fr
|
|
6
|
+
ALTER MAPPING FOR hword, hword_part, word
|
|
7
|
+
WITH unaccent, french_stem;
|
|
8
|
+
|
|
9
|
+
ALTER TABLE pg_search_documents
|
|
10
|
+
ADD COLUMN tsv_content tsvector GENERATED ALWAYS AS (
|
|
11
|
+
to_tsvector('fr', coalesce(content, ''))
|
|
12
|
+
) STORED;
|
|
13
|
+
SQL
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def down
|
|
17
|
+
execute <<-SQL
|
|
18
|
+
DROP TEXT SEARCH CONFIGURATION IF EXISTS fr;
|
|
19
|
+
ALTER TABLE pg_search_documents DROP COLUMN IF EXISTS tsv_content;
|
|
20
|
+
SQL
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/apidae/version.rb
CHANGED
data/test/dummy/bin/rails
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
APP_PATH = File.expand_path(
|
|
3
|
-
require_relative
|
|
4
|
-
require
|
|
2
|
+
APP_PATH = File.expand_path("../config/application", __dir__)
|
|
3
|
+
require_relative "../config/boot"
|
|
4
|
+
require "rails/commands"
|
data/test/dummy/bin/rake
CHANGED
data/test/dummy/bin/setup
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
require
|
|
2
|
+
require "fileutils"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
|
5
|
+
APP_NAME = "dummy"
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
def system!(*args)
|
|
8
|
+
system(*args, exception: true)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
FileUtils.chdir APP_ROOT do
|
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
|
14
|
+
# Add necessary setup steps to this file.
|
|
10
15
|
|
|
11
16
|
puts "== Installing dependencies =="
|
|
12
|
-
system "gem install bundler --conservative"
|
|
13
|
-
system
|
|
17
|
+
system! "gem install bundler --conservative"
|
|
18
|
+
system("bundle check") || system!("bundle install")
|
|
14
19
|
|
|
15
20
|
# puts "\n== Copying sample files =="
|
|
16
21
|
# unless File.exist?("config/database.yml")
|
|
17
|
-
#
|
|
22
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
|
18
23
|
# end
|
|
19
24
|
|
|
20
25
|
puts "\n== Preparing database =="
|
|
21
|
-
system "bin/
|
|
26
|
+
system! "bin/rails db:prepare"
|
|
22
27
|
|
|
23
28
|
puts "\n== Removing old logs and tempfiles =="
|
|
24
|
-
system "
|
|
25
|
-
system "rm -rf tmp/cache"
|
|
29
|
+
system! "bin/rails log:clear tmp:clear"
|
|
26
30
|
|
|
27
31
|
puts "\n== Restarting application server =="
|
|
28
|
-
system "
|
|
32
|
+
system! "bin/rails restart"
|
|
33
|
+
|
|
34
|
+
# puts "\n== Configuring puma-dev =="
|
|
35
|
+
# system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
|
|
36
|
+
# system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
|
|
29
37
|
end
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative "boot"
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rails/all"
|
|
4
4
|
|
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
|
6
|
+
# you've limited to :test, :development, or :production.
|
|
5
7
|
Bundler.require(*Rails.groups)
|
|
6
|
-
require "apidae"
|
|
7
8
|
|
|
8
9
|
module Dummy
|
|
9
10
|
class Application < Rails::Application
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
# -- all .rb files in that directory are automatically loaded.
|
|
11
|
+
# Initialize configuration defaults for originally generated Rails version.
|
|
12
|
+
config.load_defaults 5.0
|
|
13
13
|
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
14
|
+
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
|
15
|
+
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
|
16
|
+
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
|
17
|
+
config.autoload_lib(ignore: %w[assets tasks])
|
|
18
|
+
|
|
19
|
+
# Configuration for the application, engines, and railties goes here.
|
|
20
|
+
#
|
|
21
|
+
# These settings can be overridden in specific environments using the files
|
|
22
|
+
# in config/environments, which are processed later.
|
|
23
|
+
#
|
|
24
|
+
# config.time_zone = "Central Time (US & Canada)"
|
|
25
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
|
17
26
|
|
|
18
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
19
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
20
|
-
# config.i18n.default_locale = :de
|
|
21
27
|
config.apidae_auth = :dummy_auth
|
|
28
|
+
|
|
29
|
+
# Use sql schema format
|
|
30
|
+
config.active_record.schema_format = :sql
|
|
22
31
|
end
|
|
23
32
|
end
|
|
24
|
-
|
data/test/dummy/config/boot.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
|
1
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
|
3
2
|
|
|
4
|
-
require
|
|
5
|
-
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
|
|
3
|
+
require "bundler/setup" # Set up gems listed in the Gemfile.
|
|
@@ -1,41 +1,75 @@
|
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
|
2
|
+
|
|
1
3
|
Rails.application.configure do
|
|
2
4
|
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
5
|
|
|
4
|
-
# In the development environment your application's code is reloaded
|
|
5
|
-
#
|
|
6
|
+
# In the development environment your application's code is reloaded any time
|
|
7
|
+
# it changes. This slows down response time but is perfect for development
|
|
6
8
|
# since you don't have to restart the web server when you make code changes.
|
|
7
|
-
config.
|
|
9
|
+
config.enable_reloading = true
|
|
8
10
|
|
|
9
11
|
# Do not eager load code on boot.
|
|
10
12
|
config.eager_load = false
|
|
11
13
|
|
|
12
|
-
# Show full error reports
|
|
13
|
-
config.consider_all_requests_local
|
|
14
|
-
|
|
14
|
+
# Show full error reports.
|
|
15
|
+
config.consider_all_requests_local = true
|
|
16
|
+
|
|
17
|
+
# Enable server timing.
|
|
18
|
+
config.server_timing = true
|
|
19
|
+
|
|
20
|
+
# Enable/disable caching. By default caching is disabled.
|
|
21
|
+
# Run rails dev:cache to toggle caching.
|
|
22
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
|
23
|
+
config.action_controller.perform_caching = true
|
|
24
|
+
config.action_controller.enable_fragment_cache_logging = true
|
|
25
|
+
|
|
26
|
+
config.cache_store = :memory_store
|
|
27
|
+
config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{2.days.to_i}" }
|
|
28
|
+
else
|
|
29
|
+
config.action_controller.perform_caching = false
|
|
30
|
+
|
|
31
|
+
config.cache_store = :null_store
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
|
35
|
+
config.active_storage.service = :local
|
|
15
36
|
|
|
16
37
|
# Don't care if the mailer can't send.
|
|
17
38
|
config.action_mailer.raise_delivery_errors = false
|
|
18
39
|
|
|
40
|
+
# Disable caching for Action Mailer templates even if Action Controller
|
|
41
|
+
# caching is enabled.
|
|
42
|
+
config.action_mailer.perform_caching = false
|
|
43
|
+
|
|
44
|
+
config.action_mailer.default_url_options = { host: "localhost", port: 3000 }
|
|
45
|
+
|
|
19
46
|
# Print deprecation notices to the Rails logger.
|
|
20
47
|
config.active_support.deprecation = :log
|
|
21
48
|
|
|
49
|
+
# Raise exceptions for disallowed deprecations.
|
|
50
|
+
config.active_support.disallowed_deprecation = :raise
|
|
51
|
+
|
|
52
|
+
# Tell Active Support which deprecation messages to disallow.
|
|
53
|
+
config.active_support.disallowed_deprecation_warnings = []
|
|
54
|
+
|
|
22
55
|
# Raise an error on page load if there are pending migrations.
|
|
23
56
|
config.active_record.migration_error = :page_load
|
|
24
57
|
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
58
|
+
# Highlight code that triggered database queries in logs.
|
|
59
|
+
config.active_record.verbose_query_logs = true
|
|
60
|
+
|
|
61
|
+
# Highlight code that enqueued background job in logs.
|
|
62
|
+
config.active_job.verbose_enqueue_logs = true
|
|
63
|
+
|
|
64
|
+
# Raises error for missing translations.
|
|
65
|
+
# config.i18n.raise_on_missing_translations = true
|
|
29
66
|
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
config.assets.digest = true
|
|
67
|
+
# Annotate rendered view with file names.
|
|
68
|
+
config.action_view.annotate_rendered_view_with_filenames = true
|
|
33
69
|
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
# Raises helpful error messages.
|
|
37
|
-
config.assets.raise_runtime_errors = true
|
|
70
|
+
# Uncomment if you wish to allow Action Cable access from any origin.
|
|
71
|
+
# config.action_cable.disable_request_forgery_protection = true
|
|
38
72
|
|
|
39
|
-
#
|
|
40
|
-
|
|
73
|
+
# Raise error when a before_action's only/except options reference missing actions.
|
|
74
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
|
41
75
|
end
|