EyeSeeTea / dataset-configuration-blessed

Enhanced dataset manager Dhis2 app (blessed repository)
GNU General Public License v3.0
0 stars 1 forks source link

indicators cannot be deleted/excluded of dataset #149

Closed ErikaMichelet closed 6 years ago

ErikaMichelet commented 6 years ago

Dataset CFFM1807 created for ICAL and Shelter. As per country office request, i tried to delete indicators GL-LB111/R and GL-LB801/I without success. I did create a new dataset with the same indicators but excluding those two, but they appear in the new dataset also (even though I did not select them at first).

tokland commented 6 years ago

I could reproduce the problem. After some debugging, I've detected a very weird thing in your database that is causing it: some indicators and dataElement have the same uid (Unique ID). Check for example or "GL-LB111/R":

https://latestgors.nrc.no/dhis-web-maintenance/#/edit/dataElementSection/dataElement/ZDONOAJJNBV https://latestgors.nrc.no/dhis-web-maintenance/#/edit/indicatorSection/indicator/ZDONOAJJNBV

As is name indicates, a uid should be unique across all models. In any case, we can change our code so it works even with duplicate uids, this will be on the next release.

ErikaMichelet commented 6 years ago

I thought about checking the uid... next time I will do it first :) I assume we should correct it here... I will do it tomorrow (so you have time to stop me if you prefer me not to touch it :) Thank you Arnau

adrianq commented 6 years ago

Hi Erika, Arnau plans to investigate this issue a bit more tomorrow morning. We want to quickly analyse the latest dump of gors and search for other duplicates and decide how to proceed. If you don't mind do not make any change for the moment, we will come back to you tomorrow afternoon.

tokland commented 6 years ago

I've run a full scan on the gors metadata, and we have 4 collisions of dataElements/indicators (two of these we already knew about), no other model has this problem:

{
  "XMRmqF9reP5": ["dataElements", "indicators"],
  "UzT7DSkkbxH": ["dataElements", "indicators"],
  "ZDONOAJJNBV": ["dataElements", "indicators"],
  "wFrRdK9XyIM": ["dataElements", "indicators"],
}

Even a single collision is extremely unlikely, 4 collisions is pretty much impossible, something happened, either a bug in the app that created those objects or a human editing on the DB trying to fix something, it's hard to say.

With many other models, we could just change the uid (since the internal relationships use a different auto-incremented id), but not here, dataElements and indicators uids are used in the custom forms to identify the fields, so we should re-save every form. It's doable, but we can introduce bugs (I am thinking of browsers with forms cached, that would be a problem). I think it's better just to support these duplicates in our code and leave the DB as is (unless we detect further, more serious problems):

https://github.com/EyeSeeTea/dataset-configuration/pull/344