Skip to content

Feature: Merge two datasets when importing

Liv M requested to merge livgm/drip:feature/double-import into main

Why this change?

When importing, the user currently has two options - start from scratch ("delete all") or delete only the days from the database for which both files have entries. That means that even if day 1 in the import file only has a note entry, all previous information from day 1 would be lost. Especially since I'm currently working on making third-party data easier to import, it seems like a sensible option to allow for merging of the two datasets.

Description

When importing the user can choose between "Merge" or "Delete existing". The "Merge" option tries to incorporate both data sets into a unified one.

If only one dataset contains an entry for a specific day, this is obviously kept/copied.

In case of a conflict, we look at each symptom separately.

If only one of the datasets contains an entry for this symptom, this is copied.

If both datasets have an entry for the same day and the same symptom, the action depends on which symptom is concerned. Some are easily mergeable and some cannot reasonably be merged. For those where merging does not make sense, the imported value overwrites the existing value.

(e.g. Sex: if the existing data contains {condom: true} and the import data contains {pill:true}, we can simply combine these to {condom:true, pill:true}. For temperature, this does not make sense, neither does it for bleeding)

I have tested this MR:

  • tested this PR on iOS simulator/physical device,
  • tested this PR on Android simulator/physical device,
  • ran e2e tests.

I implemented this merge functionality that changes depending on the symptoms concerned to preserve the most of both datasets. I also changed the order of the "Import" buttons in iOS.

Steps to Test or Reproduce

Put some dummy data - hit export.

Change data in app - go to Import -> Merge -> Look at changes!

Reviewing

Here's what I am looking for feedback on in particular:

  • Word choice regarding the description/ buttons. I think the "Delete existing"-option could be worded even stronger. Is "merging" the appropriate word for the functionality that I am introducing?
  • Are there symptoms that should be merged in a different way?

In addition:

Merge request reports