-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Hide old form versions #2216
Hide old form versions #2216
Conversation
@@ -171,52 +171,48 @@ public int updateForm(ContentValues values, String where, String[] whereArgs) { | |||
|
|||
public List<Form> getFormsFromCursor(Cursor cursor) { | |||
List<Form> forms = new ArrayList<>(); | |||
if (cursor != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please describe why you've made this change? They look mostly equivalent except that in the new version the cursor is not closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because the cursor is somehow reused (no created again) if we go back from a survey (for example after saving) so I can't close that cursor because then I'm not able to read rows again.
Btw I need to investigate why we are moved back to forms list after saving a form it was always the main menu as I remember...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks! That kind of info is perfect for a commit message description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😭 We did actually start having a conversation about this change, we just didn't go deep enough. (See #2687 (comment) for later implications)
FormsProviderAPI.FormsColumns.DATE} | ||
); | ||
|
||
for (Form form : forms) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is n2 in the number of forms. In practice it probably doesn't make a visible difference (maybe on slower devices with lots of forms?) but best to avoid if possible.
This currently uses numerically sorted version and then date/time entered in forms database in case of null versions to identify the latest form. I propose we sort just by date/time entered in the forms database instead. I can't think of a case in which a user wouldn't want to show just the version they last moved to the device. The current approach has a few problems:
Additionally, sorting using both columns makes the code more complex. If you were just using date/time you could do it through the query, right, @grzesiek2010? Apologies for only thinking of these things now! @yanokwa and others, does only showing the latest version transferred to the device make sense? |
One "bad" behavior if only database No matter what, I do think we need to provide a way for users to show all versions. That would be a good setting to add to the Form update group in Form management settings. |
I think the proposed change to the current PR is necessary. We don't want to break compatibility with Ona and the risk for a user clock going backward in time and not being able to see the forms in the future is fixable: delete the blank form. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- only use
created_at
date/time to determine latest form - add setting to show all form versions
I don't think the version comparison is working anyway. If I add version 3, I see version 3. If I then add version 13, I see only version 13. If I then add version 4, I see only version 4. That is the desired behavior -- only the latest form to be added is shown.
@grzesiek2010 If you are able to address those issues during your day Tuesday, please tag as |
dd5a3fe
to
b2fa94e
Compare
@opendatakit-bot label "needs testing" @lognaturel it's ready I'm not sure about the setting whether it should be selected by default or nor but I marked the pr as needs testing as you asked. We can fix that in the evening if needed. |
Tested with success! Verified on Android: 4.1, 4.2, 4.4, 5.1, 6.0, 7.0, 8.1 Verified cases:
|
@opendatakit-bot label "behavior verified" |
@grzesiek2010 I just realized that when I transferred different versions directly with But using just |
Closes #1694
What has been done to verify that this works as intended?
I tested the solution on a real device and I also wrote an automated test.
Why is this the best possible solution? Were any other approaches considered?
Hiding old forms is better than removing them because thanks to this approach we can still edit old saved forms.
Are there any risks to merging this code? If so, what are they?
We only hide old forms keeping them in the database. That means old saved forms are still available what makes this change less risky. I wrote an automated test so I think it's not risky and we hide old forms in an appropriate way.
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.
getodk/docs#710
Before submitting this PR, please make sure you have:
./gradlew pmd checkstyle lint findbugs
and confirmed all checks still pass.