Skip to content

Commit

Permalink
update signage view
Browse files Browse the repository at this point in the history
  • Loading branch information
juggler31 committed Dec 5, 2023
1 parent 3898467 commit f5b6f34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ <h3>{% trans "Blades" %}</h3>
<td>{{ blade.type|default_if_none:"" }}</td>
<td>{{ blade.color|default_if_none:"" }}</td>
<td>{{ blade.direction }}</td>
<td>{% for condition in object.conditions.all %}
<td>{% for condition in blade.conditions.all %}
{% if not forloop.last %}
<span>{{ condition.label }},<span>
{% else %}
Expand Down
40 changes: 24 additions & 16 deletions geotrek/signage/templates/signage/sql/post_10_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ CREATE VIEW {{ schema_geotrek }}.v_signages AS WITH v_signage_tmp AS
t.code,
t.printed_elevation,
t.manager_id,
{% comment %} t.condition_id, {% endcomment %}
p.labels AS "Condition",
p.labels AS "Conditions",
t.sealing_id,
t.access_id,
t.structure_id,
Expand All @@ -29,14 +28,17 @@ CREATE VIEW {{ schema_geotrek }}.v_signages AS WITH v_signage_tmp AS
FROM signage_signage t
left join core_topology e on t.topo_object_id = e.id
left join signage_signagetype b on t.type_id = b.id
-- FROM signage_signage t,
-- signage_signagetype b,
-- core_topology e
LEFT JOIN
(SELECT a.signagecondition_id, b.label AS labels, a.signage_id
FROM signage_signagecondition b
JOIN signage_signage_conditions a ON a.signagecondition_id = b.id) p
ON t.topo_object_id = p.signage_id
LEFT JOIN ( WITH signage_condition AS (
SELECT a_1.signagecondition_id,
b_2.label AS labels,
a_1.signage_id
FROM signage_signagecondition b_2
JOIN signage_signage_conditions a_1 ON a_1.signagecondition_id = b_2.id
)
SELECT array_to_string(array_agg(signage_condition.labels), ', '::text, '_'::text)::character varying AS labels,
signage_condition.signage_id
FROM signage_condition
GROUP BY signage_condition.signage_id) p ON t.topo_object_id = p.signage_id
WHERE e.deleted = FALSE )
SELECT a.id,
e.name AS "Structure",
Expand All @@ -47,7 +49,7 @@ SELECT a.id,
{% endfor %}
a.code AS "Code",
b.label AS "Type",
-- c.label AS "State",
c.labels AS "States",
{% for lang in MODELTRANSLATION_LANGUAGES %}
a.description_{{ lang }} AS "Description {{ lang }}",
{% endfor %}
Expand All @@ -70,11 +72,17 @@ SELECT a.id,
a.geom
FROM v_signage_tmp a
LEFT JOIN signage_signagetype b ON a.type_id = b.id
LEFT JOIN (SELECT a.signagecondition_id, b.label AS labels, a.signage_id
FROM signage_signagecondition b
JOIN signage_signage_conditions a ON a.signagecondition_id = b.id) c
ON a.id = c.signage_id
-- LEFT JOIN infrastructure_infrastructurecondition c ON a.condition_id = c.id
LEFT JOIN ( WITH signage_condition AS (
SELECT a_1.signagecondition_id,
b_1.label AS labels,
a_1.signage_id
FROM signage_signagecondition b_1
JOIN signage_signage_conditions a_1 ON a_1.signagecondition_id = b_1.id
)
SELECT array_to_string(array_agg(signage_condition.labels), ', '::text, '_'::text)::character varying AS labels,
signage_condition.signage_id
FROM signage_condition
GROUP BY signage_condition.signage_id) c ON a.id = c.signage_id
LEFT JOIN signage_sealing d ON a.sealing_id = d.id
LEFT JOIN authent_structure e ON a.structure_id = e.id
LEFT JOIN infrastructure_infrastructureaccessmean i ON a.access_id = i.id
Expand Down

0 comments on commit f5b6f34

Please sign in to comment.