We have a custom app which allows uploading of 2000+ events (without registration) from Excel file and the frequency is monthly. Say we have uploaded events for Jan 2021 and later need to upload again with updated data.
I found that bulk delete of TEI and events using strategy=DELETE has been discontinued (it was there possibly till 2.29). Now the option is to delete one by one. As we need to delete old events for that month and create new, it is quite challenging to send 2000+ API calls and ensuring they come back in reasonable time while user waits in front-end.
I also found that we can set deleted=true in table programstageinstance where the events are stored. But question is - how to send update SQL command directly to backend from web app?
@Mahmud To answer your question, it is not possible to send update SQL command directly to backend from web app. SQL commands can be executed directly on the database if you have access to it. For example, by using pgadmin or psql and connecting to the db directly.
But bulk delete of TEI and events using importStrategy=DELETE should still be supported. Home - DHIS2 Documentation This is the documentation for 2.34. But it should still be supported. Did you face any issue when trying to bulk delete as mentioned in the attached documentation link?
It is in documentation, but believe me, we had passed sleepless nights to understand why it is not working. There is no ‘importStrategy’ but ‘strategy’ is a valid keyword.
In the following screen you see I am passing 2 event ids -
@Mahmud That is interesting and it looks like a bug. Please create a jira issue with all the necessary details and specific version numbers and we will definitely look into it and hopefully resolve it.
In the meantime, directly accessing the db might be the only choice.
Hi @Ameen
We are delivering a web app that allows uploading monthly events. Directly accessing the DB is out of scope. To the Ministry it will be treated as - the app not working as you upload 2 times and records will continue to grow.
@Mahmud In that case, it would help us if you can create a jira issue with all the necessary details. We can try to prioritize it and resolve the issue for the next patch release. You can share the jira issue in this thread once its created.
@Stian nothing happens after bulk delete, deleted flag is not set. We do not realy need hard delete from database. As long as soft delete happens and it is not displayed in the front end it would be fine. Which is not happening when multiple event IDs are sent in the API.
there is another option you can use in the meanwhile for versions >= 2.30. This endpoint accepts a SYNC strategy that allows to create, delete and update events in a single query (/api/events?strategy=SYNC). You just have to set the property deleted to false in the event payload ({ deleted: true }).
Please I’m a bit new to this and I also want to test out the event deletion. Is there a particular IDE to use or can I just use my browser URL?
What platform is that in your screenshot? @Mahmud
Thanks in advance.