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

Send and finalize forms in oldest first order #6356

Merged
merged 19 commits into from
Aug 27, 2024

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Aug 20, 2024

Closes #6128

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

Some of the changes could have been skipped (such as sorting instances before sending/finalizing) because everything appeared to work as expected, and the tests passed (including the new ones). However, this functionality relied on implicit behavior - such as the order of rows in the database rather than on correctly maintaining the intended order. To avoid depending on such implicit factors, I decided to add explicit sorting to ensure consistent behavior in all cases.

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?

As described in the issue this requires testing:

  • Manually sending a selected set of forms
  • Auto sending forms
  • Bulk finalizing drafts

Everything should happen in the oldest first order. The order of sending forms could be tested with Central. When it comes to bulk finalizing it might require looking into the database of instances and its lastStatusChangeDate to check the dates that reflect the order of finalizing forms.

Do we need any specific form for testing your changes? If so, please attach one.

No.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@grzesiek2010 grzesiek2010 marked this pull request as ready for review August 20, 2024 19:47
Copy link
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

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

Looks great! Just one note on combining the new XML parsing with some other stuff I needed in tests recently.


private fun parseXml(file: File): Document {
return StringReader(String(file.readBytes())).use { reader ->
val parser = KXmlParser()
Copy link
Member

Choose a reason for hiding this comment

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

Ah nice! I'd just meant doing a contains, but parsing the XML is definitely more exact. How about combining the common bits here with the parsing done in StubOpenRosaServer and pulling it out to some kind of helper function/object? I think we could actually use some of this in real form download code soon as well to avoid needing to use JavaRosa's static parser.

@grzesiek2010 grzesiek2010 force-pushed the COLLECT-6128 branch 2 times, most recently from ed2bba9 to 36be8e0 Compare August 26, 2024 15:21
@JvmStatic
@Throws(XmlPullParserException::class)
fun parseXml(formInputStream: InputStream): Document {
return XFormParser.getXMLDocument(InputStreamReader(formInputStream))
Copy link
Member

Choose a reason for hiding this comment

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

I'd not noticed getXMLDocument! Maybe for the moment we can just that directly everywhere and remove this file? I'm a little worried about the extension functions as they could be confusing when working with a Document that's not an XForm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok we can do that.

@seadowg seadowg merged commit 576c294 into getodk:master Aug 27, 2024
6 checks passed
@grzesiek2010 grzesiek2010 mentioned this pull request Aug 27, 2024
6 tasks
@dbemke
Copy link

dbemke commented Aug 28, 2024

Tested with Success!

Verified on a device Android 10

Verified Cases:

  • auto sending finalized forms
  • bulk finalizing drafts
  • manually sending selected forms
  • sending registration and update form
  • sending a list of forms with one form that get status "sending failed"
  • sending a list of forms after Collect retries to send

@WKobus
Copy link

WKobus commented Aug 28, 2024

Tested with Success

Verified on device with Android 14

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

Successfully merging this pull request may close these issues.

Send submissions in oldest first order
4 participants