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

Remove submissionCreate from entity audit events #1072

Merged
merged 4 commits into from
Jan 24, 2024
Merged

Conversation

ktuite
Copy link
Member

@ktuite ktuite commented Jan 18, 2024

Closes #1036

It used to be that entity events that were triggered by a Submission (e.g. entity create OR update) would return these objects in the details:

  • sourceEvent (the actual event that caused the entity update, whether it was a submission approval, or submission creation, etc.)
  • submission (the Submission object, but only if a Submission was part of the event AND the Submission was not deleted)
  • a submissionCreate object for the Submission (if a Submission was part of the event) that had enough historical information including the creation time and instance ID to describe the Submission even if it was deleted.

Now, entity audits (accessed via /projects/.../datasets/.../entities/[uuid]/audits) have details.source. This looks like

  • source: { submission, event } (for events like create and update that were triggered by a submission)
  • source: {} (empty source object for events triggered through the API)

This now matches the structure of source returned for Entity Versions.

What has been done to verify that this works as intended?

Tests

Why is this the best possible solution? Were any other approaches considered?

We've been discussing this for a while.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.

There's a small documentation change included in this PR showing that an entityVersion source no longer contains submissionCreate. But we don't document the details of specific audit events, so the main change in this PR doesn't need a docs change.

It is super important for us making changes on frontend, though, so I'm trying to document it here 😅

Before submitting this PR, please make sure you have:

  • run make test-full and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

@ktuite ktuite requested a review from matthew-white January 18, 2024 02:58
lib/model/query/audits.js Outdated Show resolved Hide resolved
lib/model/query/audits.js Show resolved Hide resolved
lib/model/query/audits.js Outdated Show resolved Hide resolved
test/integration/api/entities.js Outdated Show resolved Hide resolved
Comment on lines 216 to 219
const details = mergeLeft(audit.details, {
sourceEvent: sourceEvent.orElse(undefined),
submissionCreate: submissionCreate.orElse(undefined),
submission: submission.orElse(undefined)
submission
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an idea (and maybe for a future PR), but what do you think about grouping sourceEvent and submission in a source object that's similar to the source object on the entity version response? I.e., details: { source: { event, submission } }

const details = mergeLeft(audit.details, sourceEvent
  .map(event => ({ source: { event, submission } }))
  .orElse(undefined));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is worth thinking about when we get to getodk/central#583, yes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is worth doing now. I hadn't looked closely at the entity versions, but I don't like that this is called details.sourceEvent and details.submission but an entity version has source.event and source.submission.

@ktuite ktuite merged commit df8ab56 into master Jan 24, 2024
5 checks passed
@ktuite ktuite deleted the ktuite/rm_sub_create branch January 24, 2024 23:42
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.

Get rid of submissionCreate from GET entities/:uuid/audits
2 participants