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

Save date when transition ran in document infodoc #9012

Closed
dianabarsan opened this issue Apr 17, 2024 · 6 comments · Fixed by #9013
Closed

Save date when transition ran in document infodoc #9012

dianabarsan opened this issue Apr 17, 2024 · 6 comments · Fixed by #9013
Assignees
Labels
Type: Improvement Make something better
Milestone

Comments

@dianabarsan
Copy link
Member

What feature do you want to improve?
When a transition runs over a document, we store some metadata about this in the infodoc. It ends up looking like:

{
  "_id": "uuid-info",
  "type": "info",
  "doc_id": "uuid",
  "initial_replication_date": "2024-04-10T08:23:45.275Z",
  "latest_replication_date": "2024-04-10T08:23:45.275Z",
  "transitions": {
    "registration": {
      "last_rev": "1-471765b1ac3cdebe9bae8c3ae43a08c6",
      "seq": "68636-g1AAAAadeJy91D1OwzAYBmCLIiEhRgriCkiNkthp6wmuAK0P4L9QSmhRf1i5AgsLGwu0vgIDF2DtwsABegZa8zX2mKGK1EyfFCmfHvl97QwhdNSrKRTK4VT2lLj0sxEHN3yg-N1t42E0VMH4UQYym44nehRkQ8mzDP7c40jUGev2ezWB0Gl8D98OIoljzaMSKwsd0TaOjYKJc2PmnvKWU3BEcdKmJbYWUvBWFFAYcWHt2lHqvzmFpLjF26TE1vLpbBRWwMl0POU1p6RpSHnYqjYgUHRF35iZo5w0XFdwLGkUVxsQKObiydqVP5XnnBIKSkIiqw0IFOvBPrpm7MVhzg5zTKJxK8Wi0ojA0QEHjA9osI9p4mJKOGnqovLuLiZwzMAB48_aL8c5_sw5Qmusqao0KnCswAHjirGFb863u9oREbRZVOKdhgWlWcB4N2bpw0ocR8t2GuKqw4LSLGHAi2P96fy414aoRPFmic39fyUGPsU",
      "ok": true
    },
    "default_responses": {
      "last_rev": "1-471765b1ac3cdebe9bae8c3ae43a08c6",
      "seq": "68636-g1AAAAadeJy91D1OwzAYBmCLIiEhRgriCkiNkthp6wmuAK0P4L9QSmhRf1i5AgsLGwu0vgIDF2DtwsABegZa8zX2mKGK1EyfFCmfHvl97QwhdNSrKRTK4VT2lLj0sxEHN3yg-N1t42E0VMH4UQYym44nehRkQ8mzDP7c40jUGev2ezWB0Gl8D98OIoljzaMSKwsd0TaOjYKJc2PmnvKWU3BEcdKmJbYWUvBWFFAYcWHt2lHqvzmFpLjF26TE1vLpbBRWwMl0POU1p6RpSHnYqjYgUHRF35iZo5w0XFdwLGkUVxsQKObiydqVP5XnnBIKSkIiqw0IFOvBPrpm7MVhzg5zTKJxK8Wi0ojA0QEHjA9osI9p4mJKOGnqovLuLiZwzMAB48_aL8c5_sw5Qmusqao0KnCswAHjirGFb863u9oREbRZVOKdhgWlWcB4N2bpw0ocR8t2GuKqw4LSLGHAi2P96fy414aoRPFmic39fyUGPsU",
      "ok": true
    },
      "update_sent_by": {
      "last_rev": "1-471765b1ac3cdebe9bae8c3ae43a08c6",
      "seq": "68636-g1AAAAadeJy91D1OwzAYBmCLIiEhRgriCkiNkthp6wmuAK0P4L9QSmhRf1i5AgsLGwu0vgIDF2DtwsABegZa8zX2mKGK1EyfFCmfHvl97QwhdNSrKRTK4VT2lLj0sxEHN3yg-N1t42E0VMH4UQYym44nehRkQ8mzDP7c40jUGev2ezWB0Gl8D98OIoljzaMSKwsd0TaOjYKJc2PmnvKWU3BEcdKmJbYWUvBWFFAYcWHt2lHqvzmFpLjF26TE1vLpbBRWwMl0POU1p6RpSHnYqjYgUHRF35iZo5w0XFdwLGkUVxsQKObiydqVP5XnnBIKSkIiqw0IFOvBPrpm7MVhzg5zTKJxK8Wi0ojA0QEHjA9osI9p4mJKOGnqovLuLiZwzMAB48_aL8c5_sw5Qmusqao0KnCswAHjirGFb863u9oREbRZVOKdhgWlWcB4N2bpw0ocR8t2GuKqw4LSLGHAi2P96fy414aoRPFmic39fyUGPsU",
      "ok": false
    }
  }
}

The information that we store is:

  • the transition name
  • the rev of the document which it updated
  • the sequence of the database (which is not super relevant)
  • whether the transition was successful

Describe the improvement you'd like
While debugging an issue where a field, that was supposed to be added by a transition, was missing from a generated sms message, there was no way of knowing when the transition ran, specifically whether it ran before or after the SMS message had been generated.
I'm suggesting we add an additional field to infodoc transition entries to store the date when the transition edited the document.

Describe alternatives you've considered
Leave it as it is.

Additional context
Having this information would definitively exclude the delayed sentinel scenario as an explanation for issues like https://github.com/medic/config-gandaki/issues/38
related issue #9011

@dianabarsan dianabarsan added the Type: Improvement Make something better label Apr 17, 2024
@dianabarsan dianabarsan self-assigned this Apr 17, 2024
@dianabarsan dianabarsan changed the title Save date when transition updated a document Save date when transition ran in document infodoc Apr 17, 2024
@dianabarsan dianabarsan added this to the 4.7.0 milestone Apr 17, 2024
@dianabarsan
Copy link
Member Author

@1yuv @binokaryg @garethbowen
I'd appreciate your opinions on this. The change is really simple and I already have a PR. I can't think of a reason not to add this, but deferring to you if you have objections or thoughts about formats and whatnot.
Thanks a lot!

@garethbowen
Copy link
Member

Including the date seems like a no brainer! Maybe it could use a better name... "timestamp" isn't very descriptive. What about "execution_date" or something?

@1yuv
Copy link
Member

1yuv commented Apr 17, 2024

Thanks @dianabarsan, I can't draw a picture how will this help with #9011 ? Will there be another PR that will re-run transition based on newly introduced timestamp? Do we capture this date field only once, or can be changed based on the result of ok and this date field? In that case I'd rename this to last_execution_date.

@dianabarsan
Copy link
Member Author

Most transitions don't run more than once, @1yuv , the intention for this is to add more information into when the transition ran, to know for certain that it had run before or after another event (for example, before or after an SMS was generated).

@dianabarsan dianabarsan linked a pull request Apr 18, 2024 that will close this issue
5 tasks
@dianabarsan
Copy link
Member Author

"execution_date"

Thanks for the feedback, I changed it to run_date.
I recently read a story about a shipwreck from the 18th century, and the word "execution" rings sadly to me.

@garethbowen
Copy link
Member

I recently read a story about a shipwreck from the 18th century, and the word "execution" rings sadly to me.

Oof, yeah, run_date is good...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Improvement Make something better
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants