Giter Club home page Giter Club logo

Comments (5)

sufyanAbbasi avatar sufyanAbbasi commented on July 19, 2024

It seems like, for some reason, while the $addLoi task appears in the task list from Firestore, when we're retrieving the taks lists from the JobEntityAndRelations in the local DB, that $addLoi task is no where to be found. Investigating further.

Hypothesis: maybe because the task ID, $addLoi is shared, the key is not unique so it gets wiped out by another task?

from ground-android.

sufyanAbbasi avatar sufyanAbbasi commented on July 19, 2024

After debugging some more, by changing the $addLoi ID to something like $addLoi123 then setting the target LOI task ID to $addLoi123, the feature began to work again as expected. With breakpoints, I can see that as we iterate over the surveys and store them into the DAO, when the same LOI task ID key is encountered, we store it there.

Given that the taskDao uses the taskId as the primary key, it gets overridden by the other tasks when loaded into the DAO. Inspecting the DB revealed the issue:

Screenshot 2024-02-28 at 6 34 18 PM

Proposed fixes:

  1. Change it from $addLoi to $addLoi<JOB ID> which maintains the unique task ID and we can use a simple startsWith() check.
  2. Do this transformation on the local DB side and remember to unparse it later at fetch time.
  3. Reconfigure the DB to use both a Primary and Secondary key, the task and job ID, something something?

from ground-android.

gino-m avatar gino-m commented on July 19, 2024

Great sleuthing, Sufy! What if we just go back to using the "addLoiTask" boolean? That way clients would be able to count on task IDs being UUIDs. @rfontanarosa does this complicate things much?

from ground-android.

sufyanAbbasi avatar sufyanAbbasi commented on July 19, 2024

I wanted to report that option 3, having two primary keys, is a completely viable option: I modified the task table, multiple choice table, and option table to use the task ID and job ID as primary keys. I have no crashes and as long as task IDs are unique within a job, the solution actually works REALLY well. Furthermore, consider the scenario in which a sufficiently lazy survey creator wanted to just copy and paste a survey schema. With this solution, they could theoretically JUST change the job ID and the two surveys could coexist on the device. In the status quo scenario, doing the copy operation would be unsafe.

The cost is a table schema update and more complicated key structures which would get in the way of migration.

from ground-android.

gino-m avatar gino-m commented on July 19, 2024

Update: We reevaluated this issue, and agreed instead on the solution outlined in google/ground-platform#1530. For now, no changes are needed Android-side. We'll eventually deprecate addLoiTask boolean, but not in this version, so closing this for now.

from ground-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.