CouncilDataProject / CouncilDataProject/cdp-backend

Add function for deleting an event (and all it's related information)

Open
#166 3 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Python
Stars
25
Forks
28
PR merge metrics
No merged PRs in 30d

Description

### Feature Description

_A clear and concise description of the feature you're requesting._

Add a function and script that will remove all of a single events details

### Use Case

_Please provide a use case to help us understand your request in context._

If an event processes incorrectly (or just from bad data) it would be useful to remove it easily.
An example of where I personally have made a mistake on uploading of events with bad data can be seen here: http://councildataproject.org/self/#/events/8ce513a84175

That event should actually be two events, each with a single session but because I uploaded two meetings with the same body name and the exact same datetime, the second event was added to the first event as a second session.

### Solution

_Please describe your ideal solution._

A function (and bin script) that will delete a provided event id and all related info under conditions:
* for each session related to the event
* delete the transcripts for each session (and the files in storage)
* delete the event body (if it isn't used by any other event)
* delete thumbnail file references (and the files in storage)
* for each event minutes items related to the event
* delete the referenced minutes item if it isn't used in any other event
* delete the referenced matter if it isn't used in any other event
* delete all the matter files if matter / minutes item was used in any other event
* delete all event minutes item files
* delete any matter status updates that are referenced to the event minutes item
* for each vote related to the event minutes item:
* delete any people (and their roles) that do not have votes on any other event
* delete the picture file in db and the stored picture file
* for each role:
* delete the seat if it is not used by any other person
* delete the seat image ref and the store image file from storage
* delete any votes that link to the event / event minutes item
* delete the event minutes item itself
* delete any indexed event grams linked to event
* delete any matter sponsers for matter refs OR people that no longer exist after all of the above
* delete the event itself

I _think_ I got everything??? [schema here](https://councildataproject.org/cdp-backend/database_schema.html)

### Alternatives

_Please describe any alternatives you've considered, even if you've dismissed them._

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.