Overview
Currently, the REST service in KoBoToolbox is only available for new submissions. We propose an enhancement that allows the REST service to be activated for edits and validation status changes as well. This will provide users with more flexibility and control over their data workflows.
Enhancement Details
To implement this change, we have added a multiple-choice option in the user interface (UI) to select the type of event for which the REST service should be activated. By default, it is set to activate only on new submissions, maintaining the current behavior. Users can now choose to enable the REST service for:
- New submissions
- Edits
- Validation status changes
These choices are stored in the database as a JSON object. However, they could also be stored in a separate column if necessary.
We have integrated these options with the hook model to ensure that the REST service acts accordingly for each type of event. Additionally, we have implemented unit tests to verify the functionality.
KoBoCAT Integration
On the KoBoCAT side, we have updated the service to respect these new event types and send the appropriate notifications to the KPI module.
Challenges with “On Delete” Event
We attempted to include an “On delete” event, but encountered an issue:
- We implemented the
_send_remove_event
method in KoBoCAT, connected to thepre_delete
event in PostgreSQL. - However, when KPI receives the
pre_delete
event, the submission has already been deleted, making it impossible for KPI to retrieve the submission data.
Suggestion
To resolve this issue, KoBoCAT could transmit the submission information to KPI before the deletion occurs. This way, KPI would have the necessary data to process the deletion event correctly.
Conclusion
This enhancement aims to provide users with greater flexibility in managing their data workflows by allowing the REST service to be activated for edits and validation status changes. We welcome feedback and suggestions from the community to further improve this feature.
Related Pull Requests
Related Issues