v0.1 with export image attachement
This commit is contained in:
parent
8235e10773
commit
2f84636b13
@ -1,17 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
from pycen import con_odk
|
||||
|
||||
sql = '''
|
||||
DROP VIEW IF EXISTS police.v_infraction_rnn;
|
||||
|
||||
CREATE VIEW police.v_infraction_rnn AS
|
||||
WITH photos as (
|
||||
SELECT
|
||||
split_part(b.data_id,':',2)::uuid data_id,
|
||||
json_data->>'__Submissions-id'::text "__Submissions-id",
|
||||
json_agg('https://odk2.cen-isere.fr/v1/projects/6/forms/infraction_rnn/submissions/'||(json_data->>'__Submissions-id'::text)||'/attachments/'||(json_data->>'photos')::text) photos
|
||||
FROM police.infraction_rnn
|
||||
WHERE tablename = 'photos_repeat'
|
||||
group by json_data->>'__Submissions-id'::text
|
||||
)
|
||||
SELECT
|
||||
inf.json_data->>'__id'::text id_infraction,
|
||||
split_part(sub.data_id,':',2)::uuid id_submission,
|
||||
"submitterName" digitiser,
|
||||
autre_catego_sensi,
|
||||
autre_type_sanct,
|
||||
catego_controle,
|
||||
catego_sensibil,
|
||||
autre_catego_sensi,
|
||||
autre_type_sanct,
|
||||
inf.json_data->>'catego_infract'::text catego_infract,
|
||||
inf.json_data->>'descrpt_infract'::text descrpt_infract,
|
||||
inf.json_data->>'nat_aff_niv_3'::text nat_aff_niv_3,
|
||||
inf.json_data->>'natinf_rn'::text natinf_rn,
|
||||
"Commentaire_remarque_nombre_de_tentes",
|
||||
"Conformit_du_contr_le",
|
||||
day "date",
|
||||
"day" "date",
|
||||
"heure",
|
||||
infract_nb,
|
||||
nat_operation,
|
||||
@ -21,9 +39,18 @@ SELECT
|
||||
nb_verb,
|
||||
nom_agent,
|
||||
type_sanct,
|
||||
ph.photos,
|
||||
"submissionDate" date_saisie,
|
||||
"updatedAt" date_maj,
|
||||
st_force2d(st_geomfromgeojson(replace(COALESCE(geom,point_carte),'\','')))::geometry(geometry, 4326) AS geom
|
||||
st_force2d(st_geomfromgeojson(replace(COALESCE(geom,point_carte),'\\','')))::geometry(geometry, 4326) AS geom
|
||||
FROM police.infraction_rnn_submissions_data AS sub
|
||||
JOIN police.infraction_rnn inf ON sub.data_id::text = inf.json_data->>'__Submissions-id'::text
|
||||
and inf.tablename = 'multiple_infract'
|
||||
JOIN photos ph ON sub.data_id::text = ph."__Submissions-id"::text
|
||||
ORDER BY 2,1 ;
|
||||
|
||||
|
||||
FROM police.infraction_rnn_submissions_data AS b
|
||||
'''
|
||||
|
||||
with con_odk.begin() as cnx:
|
||||
cnx.execute(sql)
|
||||
Loading…
x
Reference in New Issue
Block a user