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

Make sure that entity lists are consistent between follow up forms #6029

Closed
1 task
Tracked by #5991
seadowg opened this issue Mar 21, 2024 · 2 comments · Fixed by #6108
Closed
1 task
Tracked by #5991

Make sure that entity lists are consistent between follow up forms #6029

seadowg opened this issue Mar 21, 2024 · 2 comments · Fixed by #6108
Assignees
Milestone

Comments

@seadowg
Copy link
Member

seadowg commented Mar 21, 2024

Blocked by #5972

Entity lists should be the same across all follow up forms on device. Inconsistencies are unlikely to happen when using "Exactly match server", but it's fairly possible to construct a scenario where they could be inconsistent for some implementations if using manual downloads.

Acceptance

  • Given I've added an entity list manually locally (in the entity browser)
    And there are two entity follow up forms on the server
    And I've downloaded the first
    When a new entity is added on the server
    And I download the second form
    Then the new entity is included in the first form

Notes

We probably want to add something the OpenRosa API so that the client can know that a secondary instance CSV is an entity list so that we don't need to flag it manually.

One way to implement this would be to copy the entity list CSV somewhere shared when we do a form download/update. Then, OfflineEntitiesExternalDataInstanceProcessor could read this in and ignore the actually form's own CSV. This would maintain the efficiency problems(/opportunities) we have, but that might be a good idea so that we can approach #5623 without having already built a DB for entities. Alternatively, we can take the leap into a shared piece of storage (created at form download/update) for online and offline entities if we feel like we're seeing both in the entity browser is going to be important any time in the future.

@seadowg seadowg mentioned this issue Mar 21, 2024
12 tasks
@seadowg seadowg changed the title If the entity list is updated between two form downloads that share it, then the entities available to those forms will be different Make sure that entity lists are consistent between follow up forms Mar 21, 2024
@seadowg seadowg added this to the v2024.2 milestone Mar 21, 2024
@seadowg seadowg removed the blocked label Apr 3, 2024
@seadowg seadowg self-assigned this Apr 3, 2024
@seadowg
Copy link
Member Author

seadowg commented Apr 8, 2024

@grzesiek2010 would be really interested in your thoughts around the best way to move forward here. To my mind, there are two distinct approaches here:

  1. Continue combining the parsed external instance with the offline entities (see OfflineEntitiesExternalDataInstanceProcessor) while parsing forms, but grab all the entity lists with a matching from name (the entity list name) from all forms and use the newest one.
  2. Combine the "online" entity list CSV with our offline entities into one place (probably EntitiesRepository) when we download forms/update and then create a secondary instance from this when parsing forms (ignoring the form's actual CSV media file).

It feels to me like 2 makes the most sense long term and it also feels a little simpler (there's no timestamp comparisons etc). I'm thinking it would mean either adding something to ServerFormDownloader to handle the entity list "processing" after the form and media have been downloaded. I guess this would basically need to just work out if any of the media files are entity lists (which for the moment we just manually signal in the app, but will later come from the API), clear out existing online entities in storage, handle duplicates between the online and offline sets (like a locally created one that now in the list) and then save the (remaining) online entities.

How does all that sound? It's probably a little fuzzy, but I wanted to talk it through before diving in.

@grzesiek2010
Copy link
Member

Sorry for the late response!
To me, number 2 sounds like the option I would choose. It looks like there are no big cons if you also like it more.

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

Successfully merging a pull request may close this issue.

2 participants