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

Migrate bookmarks between books #1043

Merged
merged 18 commits into from
Feb 15, 2024
Merged

Migrate bookmarks between books #1043

merged 18 commits into from
Feb 15, 2024

Conversation

mgautierfr
Copy link
Member

Fix #1037

Contrary to suggested in #1037 (comment), we don't create new bookmark but update existing one (we don't delete bookmark).

If we create a new one without removing the wrong ones, we would create new bookmarks on each migration.

Copy link

codecov bot commented Jan 19, 2024

Codecov Report

Attention: Patch coverage is 53.54331% with 59 lines in your changes missing coverage. Please review.

Project coverage is 41.03%. Comparing base (c768d05) to head (6b05eeb).
Report is 116 commits behind head on main.

Files with missing lines Patch % Lines
src/library.cpp 52.33% 3 Missing and 48 partials ⚠️
src/libxml_dumper.cpp 0.00% 0 Missing and 5 partials ⚠️
src/bookmark.cpp 70.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1043      +/-   ##
==========================================
+ Coverage   39.36%   41.03%   +1.66%     
==========================================
  Files          58       58              
  Lines        4075     4187     +112     
  Branches     2245     2303      +58     
==========================================
+ Hits         1604     1718     +114     
+ Misses       1091     1003      -88     
- Partials     1380     1466      +86     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kelson42 kelson42 self-requested a review January 20, 2024 08:00
test/library.cpp Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
include/library.h Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
@mgautierfr mgautierfr force-pushed the bookmarks_migrations branch 2 times, most recently from 80b5b1c to 80a680a Compare January 22, 2024 15:47
@mgautierfr
Copy link
Member Author

Ready for a new review. New commit are either fixup! or marked with [New].

There is an open question about overload resolution between migrateBookmarks(const std::string& source, bool allowDowngrade) and migrateBookmarks(const std::string& source const std::string& target).
If used with a char* (as a literal string), cpp resolves overload to use the bool version.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase&fixup for the next review

include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
@kelson42
Copy link
Collaborator

@BPerlakiH Looks good to you (in terme of feature and interface)?

@BPerlakiH
Copy link

@BPerlakiH Looks good to you (in terme of feature and interface)?

Yes, initially it looks good to me.

test/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
@kelson42
Copy link
Collaborator

kelson42 commented Feb 6, 2024

@mgautierfr It‘s important that the piece of code detecting if a new book is available (to amke a bookmark/note update) is public and dedicated, so we can move notes on kiwix android the same way (but in kotlin), see kiwix/kiwix-android#3632

@mgautierfr
Copy link
Member Author

Ready for new review.
Previous fixup! have been already fixup.
New commits start from 7db8e03

src/library.cpp Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Show resolved Hide resolved
@mgautierfr
Copy link
Member Author

@mgautierfr It‘s important that the piece of code detecting if a new book is available (to amke a bookmark/note update) is public and dedicated, so we can move notes on kiwix android the same way (but in kotlin), see kiwix/kiwix-android#3632

I have tried to make that by making our internal (new) method public, but in fact detecting that a new book is available is not the same thing that we are doing here.

The PR is trying to resolve invalid bookmark, not migrate valid bookmark to new ones.
It seems pretty close at first sight, but it is not the same.
As @veloman-yunkan, it triggers some inconsistency. I've tried to mitigate that with documentation, but it may not be enough.

@mgautierfr
Copy link
Member Author

Rebased on main and previous fixup commits have been fixed up.

New commits start at d41a9ad

The questions about surprising behavior of migrationMode have been fixed (hopefully)

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only looked at the new commits.
For the next (hopefully final) review please fully rebase & fixup the PR (including any fixes addressing the new comments).

src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I decided to perform a full review on the final changes (rather than commit-wise) in order to increase the chances of the next review being the last one. Here are a few more things that caught my eye:

include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
include/library.h Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
test/library.cpp Outdated Show resolved Hide resolved
@mgautierfr
Copy link
Member Author

Ready for another review. All commits are fixed-up.
I have closed all discussion taken into account.
We have 3 left open discussions. We could go with the current code if we agree or we will need another round depending of our your/@kelson42 feedback.


(macOs failing is new and not related to this PR, seems to be a (broken) update in homebrew)

@mgautierfr
Copy link
Member Author

Next round of review.

I have rewritten the algorithm using input from @veloman-yunkan. It is indeed simpler.
fixup! commits have been inserted in the git history to reduce potential conflict at next rebase-fixup.

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pre-approval.

Please include the proposed final touches in the rebase&fixup and let there be green light!

include/library.h Outdated Show resolved Hide resolved
src/library.cpp Outdated Show resolved Hide resolved
@mgautierfr
Copy link
Member Author

Please include the proposed final touches in the rebase&fixup and let there be green light!

Done

This allow us to internally call thread_safe function from already
locked context.
We will need them to test flavour/date bookmarks migration.
If there is no book with the same flavour, but book with same name and
different flavour, we do the migration to the other book.
At least, it must be explicitly asked by the user.
On top of modifying the existing test, the commit also make
`MigrateBookmark` test fails as `migrateBookmarks` now migrates
from `wrong-book-id-noname` to `Dummy id`.

Fix will be provided in next commit.
At indexation time, double quote are ignored, so a title as
`TED "talks" - Business` is indexed as `ted talks business`.

By removing the quotes, we ensure that our title "phrase" is not closed
too early and we correctly search for `ted PHRASE talks PHRASE business`
instead of `ted AND talks AND business`.
`MigrationMode` was kind of defined in the context of an internal mode
used by `migrateBookmark(...)`.
But now, with `getBestTargetBookId`, it is broken.

This commit fix that and the associated implementation.
Now `UPGRADE_ONLY` will make `getBestTargetBookId` return only newer books.
and `ALLOW_DOWNGRADE` will return older books only if current book is
invalid.
@kelson42 kelson42 merged commit 1babbc0 into main Feb 15, 2024
16 checks passed
@kelson42 kelson42 deleted the bookmarks_migrations branch February 15, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow bookmarks to apply to new versions of a title
4 participants