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

Optimize detection for migration to nwtsty #108

Merged
merged 5 commits into from
Oct 16, 2021
Merged

Optimize detection for migration to nwtsty #108

merged 5 commits into from
Oct 16, 2021

Conversation

AndreasSko
Copy link
Owner

@AndreasSko AndreasSko commented Aug 25, 2021

The current approach of determining the need for migrating from nwt to nwtsty (introduced with #46) is using a heuristic, which basically checks if one side has significantly more nwtsty entries for a specific language than the other side.
This heuristic worked quite well, but can fail if the difference between both sides is not high enough. This can lead to collisions of UserMarkGUIDs:

Could not create SQLite database for exporting: [...] UNIQUE constraint failed: UserMark.UserMarkGuid

This introduces a new approach, which will check both sides for the same UserMarkGUID. If it finds a common GUID, it will check if the location of one UserMark is in nwt, while the other one is in nwstsy. If this is the case, it indicates the need for migrating to nwtsty, as obviously one side has already been migrated.

The logic for the migration is now bundled in kind of a "PreMergeHook", which bundles necessary functionality for preparing the databases for merging.

Cleanup userMark duplicates after nwtsty migration

The migration from nwt to nwtsty is working properly for "simple" locations, e.g. Bible chapters. However, the locations for appendices have DocumentIDs, which are not easily migratable (we would need to find the documentID corresponding to the nwstsy). Therefore, we skip those locations.
Skipping the locations, however, introduces the risk of UserMark collisions again, as the merger is using the locationIDs for finding those. As this is a very limited edge-case, I decided to simply remove the duplicate from the old nwt side completely. This shouldn't be a problem, as markings on the nwstsy can be considered newer.

closes #105
closes #97
closes AndreasSko/ios-jwlm#36

@coveralls
Copy link

coveralls commented Aug 25, 2021

Coverage Status

Coverage increased (+0.2%) to 86.195% when pulling 10ec326 on migrateBible into c192d0b on master.

@AndreasSko
Copy link
Owner Author

ToDo: Gomobile

Instead of returning nil when there are no TagMaps
to be merged, it's better to return an empty
slice.
@AndreasSko AndreasSko force-pushed the migrateBible branch 5 times, most recently from 03222a9 to 91cd766 Compare October 15, 2021 17:20
@AndreasSko AndreasSko marked this pull request as ready for review October 15, 2021 17:30
@AndreasSko AndreasSko changed the title Optimize detection to migrate to nwtsty Optimize detection for migration to nwtsty Oct 15, 2021
@AndreasSko
Copy link
Owner Author

AndreasSko commented Oct 15, 2021

ToDo:

@AndreasSko AndreasSko self-assigned this Oct 15, 2021
@AndreasSko AndreasSko force-pushed the migrateBible branch 2 times, most recently from 3289bc6 to 13b66e6 Compare October 16, 2021 13:12
The current approach of determining the need
of migrating
from `nwt` to `nwtsty` (introduced with !46) is
using a heuristic, which basically checks if one side
has significantly more `nwtsty` entries for a specific
language than the other side.
This heuristic worked quite well, but can fail if the
difference between both sides is not high enough.
This can lead to collisions of UserMarkGUIDs.

This introduces a new approach, which will check
both sides for the same UserMarkGUID. If it finds a
common GUID, it will check if the location of one
UserMark is in `nwt`, while the other one is in `nwstsy`.
If this is the case, it indicates the need for
migrating to `nwtsty`, as obviously one side has
already been migrated.

The logic for the migration is now bundled in kind of a
"PreMergeHook", which bundles necessary functionality
for preparing the databases for merging.
The migration from `nwt` to `nwtsty` is working
properly for "simple" locations, e.g. bible chapters.
However, the locations for appendices have
DocumentIDs, which are not easily migratable
(we would need to find the documentID
corresponding to the `nwstsy`). Therefore, we skip
those locations.

Skipping the locations, however, introduces the
risk of UserMark collisions again, as the merger
is using the locationIDs for finding those. As this
is a very limited edge-case, I decided to simply
remove the duplicate from the old `nwt` side
completely. This shouldn't be a problem, as
markings on the `nwstsy` can be considered
newer.
@AndreasSko AndreasSko merged commit 1dc7fb5 into master Oct 16, 2021
@AndreasSko AndreasSko deleted the migrateBible branch October 16, 2021 13:43
AndreasSko added a commit to AndreasSko/ios-jwlm that referenced this pull request Oct 16, 2021
In some situations it could happen that the merger
was not able to detect that one backup had already
been migrated to the Study Edition of the Revised
New World Translation, while the other one still was
using the Regular Edition. This could lead to errors
like:

> Could not create SQLite database for exporting: [...] UNIQUE constraint failed: UserMark.UserMarkGuid

This version improved the detection of such cases,
preventing those kinds of errors in the future.

More details: AndreasSko/go-jwlm#108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants