Repository navigation
Fix tag separators in the bookmarks CSV export - #4059
Open
m86hussein wants to merge 1 commit into
Open
m86hussein wants to merge 1 commit into
m86hussein wants to merge 1 commit into
Conversation
The tags column was built with `reduceOrNull { acc, tag -> "$acc$tag|" }`,
which puts the separator after the second tag instead of between tags:
[A, B] became "AB|" and [A, B, C] became "AB|C|". Untagged bookmarks got
the literal "null", and tag ids without a matching tag were written as
"null" too.
Join the resolved tag names with "|" and skip unknown ids, so untagged
bookmarks get an empty tags column like the other row types.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
tagscolumn of the bookmarks CSV export (#4058).The bug
Bookmark.getSemiColonSeparatedTagsused:tags.map { tagsList.find { tag -> tag.id == it }?.name } .reduceOrNull { tags, tag -> "$tags$tag|" }reduceOrNulluses the first name as the starting accumulator and appendstag|for each later name. So:[A]AA[A, B]AB|A|B[A, B, C]AB|C|A|B|Cnull[unknown id, B]nullB|BThe fix
tags.mapNotNull { tagsList.find { tag -> tag.id == it }?.name } .joinToString("|")An untagged bookmark now has an empty tags column, matching how
recentandreading_bookmarkrows already leave it empty.Testing
testExportBookmarksCsvSeparatesMultipleTagsAndLeavesUntaggedEmptytoBookmarkImportExportModelTest. It covers three tags, no tags, and an unresolved tag id. It fails onmainwithFirstSecond|Third|/null/nullSecond|, and passes with this change../gradlew :app:testMadaniDebugUnitTest --tests "*Bookmark*": all suites pass, except 5 tests that save the export to a file:testExportBookmarks*ProducesUri,*IncludesResolvedPageand*NumbersBookmarkIds*. Those fail identically on unmodifiedmainon Windows: Robolectric's FileProvider doesn't find the configured root for a Windows path. They should pass on CI (Linux).Fixes #4058
AI disclosure: this PR was drafted with GitHub Copilot and opened by @m86hussein, who is responsible for it.