biodiversitydata-se / biocollect

Biocollect front end application for Bioatlas
https://biocollect.biodiversitydata.se/
Other
0 stars 0 forks source link

CLean the bookedSites/ownedSites fields when deleted sites #252

Closed mathieuLU closed 6 months ago

mathieuLU commented 8 months ago

One person couldn't be displayed in the (https://biocollect.biodiversitydata.se/sft/person/edit/91df96ef-5476-1f2b-171b-10b598495576/?returnTo=/sft/project/index/89383d0f-9735-4fe7-8eb4-8b2e9e9b7b5c# "Visa bokade lokaler") because of sites removed in the database that were still in the ownedSites or bookedSites

Check if it's possible to clean that part when a site is removed. Or create a script that clean the database.

db.person.find({ownedSites:"e0201a7b-b235-48aa-a9d7-0bbd0e65a60f"}).pretty()

db.person.updateOne({"personId" : "91df96ef-5476-1f2b-171b-10b598495576"},{
    $pull:{
        ownedSites:"e0201a7b-b235-48aa-a9d7-0bbd0e65a60f"
    }
})
db.person.updateOne({"personId" : "91df96ef-5476-1f2b-171b-10b598495576"},{
    $pull:{
        bookedSites:"617a6062-65e3-0fa9-23ea-bdd8bde9366e"
    }
})
mathieuLU commented 6 months ago

There is now a confirmation message before deleting a site, to avoid mistakes... Screenshot from 2024-04-23 10-32-43

commit is https://github.com/biodiversitydata-se/biocollect/commit/4738944e9914f6bfaf1d05b4dbc11e603a2a3681

then a script has been created to clean the database. Reminder : the deleted sites/users/surveys are removed from the database. That scirpt makes sure that no deleted sites remains in the owned/booked fields => https://github.com/Lund-University-Biodiversity-data/convert-SFT-SEBMS-to-MongoDB/blob/master/script/checkOwnedBookedSites.php

mathieuLU commented 6 months ago

and now our intranet-dashboard displays these non-existing sites still in these owned/bookedSites fields

mathieuLU commented 6 months ago

done here https://github.com/Lund-University-Biodiversity-data/dashboardLUEkol/commit/65b311680180844ee9abe4394b1d2911ea27db52