Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RestAPI hooks : allow post hook for submit, edit, delete, validation status change #4812

Open
wants to merge 5 commits into
base: beta
Choose a base branch
from

Conversation

hhertout
Copy link

@hhertout hhertout commented Jan 19, 2024

Checklist

  1. If you've added code that should be tested, add tests
  2. If you've changed APIs, update (or create!) the documentation
  3. Ensure the tests pass
  4. Make sure that your code lints and that you've followed our coding style
  5. Write a title and, if necessary, a description of your work suitable for publishing in our release notes
  6. Mention any related issues in this repository (as #ISSUE) and in other repositories (as kobotoolbox/other#ISSUE)
  7. Open an issue in the docs if there are UI/UX changes

Description

Allow events for each submission:

  • On submit
  • On edit
  • On delete
  • On validation status change

Frontend

  • Adding in the rest api form options to select the event related to the submission change state.
  • Retrieve the current configuration and can edit it.

image

Backend

  • Retrieve the event from kobocat
  • Creating the on_event field in table hook
  • Compute the user configuration with the submitted event to create hook log
    It create only one row in database (hooklog table) for each new submission, or deletion, like the actual process.
    It create one row in database (hooklog table) for each validation status changes or edition of the submission.

In case of retry, it keep the uid hook log and apply "tries" changes to it (with args parameters of celery retry async def) to prevent duplication hook log row.
https://github.com/kobotoolbox/kpi/compare/beta...geohyd:kpi:hook_crud_REST?expand=1#diff-31cba572d024445407a36a2c229103a835632da45f069eb4e804c074e1896a33R101

  • Creating the event field in table hooklog

Related issues

kobotoolbox/kobocat#572

This PR is related to : kobotoolbox/kobocat#916

To be more precise, we also created an issue for side effect we noticed on the submission data edition when the hook fail and is in the retry process.
#4817

@jnm
Copy link
Member

jnm commented Jan 30, 2024

Hi @hhertout, thanks for your recent contributions. I appreciate the labor and enthusiasm.

I need to emphasize, however, that larger changes like this need to have discussion and consensus on the functionality and implementation approach—and it would hopefully save you time if we had these discussions before you wrote a lot of code.

If you're planning to make more contributions like this, please start a discussion at https://community.kobotoolbox.org/c/feature-wishlist/6. Since you are a developer and willing to do the work yourself, you're welcome to ping me @jnm directly for a faster response.

@mtyszler
Copy link

Any updates here?

@jdugh
Copy link

jdugh commented Apr 23, 2024

Hi @mtyszler,
I will create a discussion as suggested by jnm for this PR.
For this moment, we used this feature in our own instance.
We encounter only a problem on the "delete" route (The submission is deleted before it can be forwarded to the rest service ...).
We will get back to you shortly.

@mtyszler
Copy link

Hi @mtyszler, I will create a discussion as suggested by jnm for this PR. For this moment, we used this feature in our own instance. We encounter only a problem on the "delete" route (The submission is deleted before it can be forwarded to the rest service ...). We will get back to you shortly.

Ok, tks.

In my case the delete is not relevant. I just want to trigger a gitlab pipeline upon update (similar to when a new submission is made)

@mtyszler
Copy link

Sorry to bother, but do you have any idea when this might be available? I'm asking because I'm testing a few workflows, and if this is not available I need some sort of cron job to check for updates periodically.

Tks

@jdugh
Copy link

jdugh commented Apr 29, 2024

This PR is not going to be integrated any time soon, dsl.
It must first be discussed with the community. See if they are ok, if they want changes etc.
If your instance is a local instance, what you can do is grab the source code from the PR and apply it to your version.

@mtyszler
Copy link

This PR is not going to be integrated any time soon, dsl. It must first be discussed with the community. See if they are ok, if they want changes etc. If your instance is a local instance, what you can do is grab the source code from the PR and apply it to your version.

No, I'm using the EU kobotoolbox server... So I'll need to figure a workaround

@jdugh
Copy link

jdugh commented Jun 6, 2024

Hi @jnm ,

Let me add some context information:
We needed this feature on our own Kobotoolbox instance, so we developed it. And we would like to share with you our development to contribute to the project (and this functionality seems to be expected by "a few" users), and if the PR is accepted, it will be easier for us to do the merges with new release 😄.

But you're right, we are create too quickly this PR.
That's why I created a post on feature-wishlist, right here:
https://community.kobotoolbox.org/t/enhancing-rest-service-for-edits-and-validation-status-changes-in-kobotoolbox/53923

We are available to exchange, to modify our code, etc., without problem, quite the contrary!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants