dthonon / Client_API_VN

Export from VisioNature (Biolovision) web site to local postgresql database
https://dthonon.github.io/Client_API_VN/
GNU General Public License v3.0
4 stars 1 forks source link

Save forms before saving child data #294

Closed lpofredc closed 1 year ago

lpofredc commented 2 years ago

This process is currently problematic if you want to perform triggers on form data as it is currently the case for vigie-nature protocol data. It would be preferable to firstly record the form and then the data from the form.

https://github.com/dthonon/Client_API_VN/blob/a42180f45f7713bc36ed601a6f4694260867612e/src/export_vn/store_postgresql.py#L1046-L1080

dthonon commented 2 years ago

It is not going to be an easy modification. forms_data is built during the loop on all items in the dict and date_start, date_stop are computed across all sightings in the form.

I would have to store each sighting in a temporary list, create the form with all its attributes, and then store observations/sightings from this list. Is this what you expect ?

lpofredc commented 2 years ago

Ok, i added a new trigger on forms_json to trigger observation upsert after form insert or update.