Submissions.newVersion(): reduce repeated data#1606
Merged
alxndrsn merged 4 commits intogetodk:masterfrom Sep 6, 2025
Merged
Conversation
1. only return data from the db which is not already available 2. reduce nested queries 3. only update the `current` row in submission_defs 4. add extra JOIN on submission_defs to return root row's userAgent (necessary to achieve 4)
2 tasks
added 2 commits
September 5, 2025 18:03
sadiqkhoja
reviewed
Sep 5, 2025
| `) | ||
| .then(({ submissionDefId, submissionDefCreatedAt, ...submissionData }) => // TODO/HACK: reassembling this from bits and bobs. | ||
| new Submission({ id: deprecated.submissionId, ...submissionData }, { | ||
| currentVersion: new Submission.Def({ |
Contributor
There was a problem hiding this comment.
Can we disable these eslint rules for the block of code instead of each line?
/* eslint-disable key-spacing, no-multi-spaces */
....
....
/* eslint-enable key-spacing, no-multi-spaces */
sadiqkhoja
approved these changes
Sep 5, 2025
Contributor
sadiqkhoja
left a comment
There was a problem hiding this comment.
except for one comment, rest looks good to me
brontolosone
approved these changes
Sep 6, 2025
Contributor
brontolosone
left a comment
There was a problem hiding this comment.
And so much more readable! To me at least.
2 tasks
alxndrsn
pushed a commit
to alxndrsn/odk-central-backend
that referenced
this pull request
Sep 8, 2025
Noted while working on getodk#1606
2 tasks
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
currentrow in submission_defsNeater rewrite of #1544
Related: getodk/central#1170
What has been done to verify that this works as intended?
CI!
Why is this the best possible solution? Were any other approaches considered?
Discussion at #1544; this is a neater rewrite of that, specifically tackling the
Submissions.createVersion()function, where thexmlfield was previously passed to the database and then returned.This PR could be changed to return query formatting to match the original more closely. To me this makes understanding the query significantly harder.
Potential follow-ups:
Submissions.createNew(). It looks like the query can be inverted and simplified.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?
Should not affect users.
Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.
No.
Before submitting this PR, please make sure you have:
make testand confirmed all checks still pass OR confirm CircleCI build passes