From 89bbdb17fb4ed1cbe99c14f389940e0f91093a10 Mon Sep 17 00:00:00 2001 From: NarwhalHorns Date: Sat, 21 Feb 2026 10:26:36 +0000 Subject: [PATCH] Utilize tracker for library duplicate detection (#2978) Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- CHANGELOG.md | 1 + .../main/sqldelight/tachiyomi/data/mangas.sq | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cf728ffb..29f65c584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Reword download reindexing message to avoid confusion ([@MajorTanya](https://github.com/MajorTanya)) ([#2874](https://github.com/mihonapp/mihon/pull/2874)) - Rework internals for better performance ([@Lolle2000la](https://github.com/Lolle2000la)) ([#2955](https://github.com/mihonapp/mihon/pull/2955)) - Optimize tracked library filter ([@NarwhalHorns](https://github.com/NarwhalHorns)) ([#2977](https://github.com/mihonapp/mihon/pull/2977)) +- Utilize tracker for library duplicate detection ([@NarwhalHorns](https://github.com/NarwhalHorns)) ([#2977](https://github.com/mihonapp/mihon/pull/2978)) ### Changed - Update tracker icons ([@AntsyLich](https://github.com/AntsyLich)) ([#2773](https://github.com/mihonapp/mihon/pull/2773)) diff --git a/data/src/main/sqldelight/tachiyomi/data/mangas.sq b/data/src/main/sqldelight/tachiyomi/data/mangas.sq index ff607e9d9..8125360c0 100644 --- a/data/src/main/sqldelight/tachiyomi/data/mangas.sq +++ b/data/src/main/sqldelight/tachiyomi/data/mangas.sq @@ -118,12 +118,23 @@ AND source = :sourceId; getDuplicateLibraryManga: WITH +track_dupes AS ( + SELECT S2.manga_id + FROM manga_sync S1 + INNER JOIN manga_sync S2 + ON S1.sync_id = S2.sync_id + AND S1.remote_id = S2.remote_id + AND S1.manga_id != S2.manga_id + WHERE S1.manga_id = :id +), duplicates AS ( - SELECT * - FROM mangas + SELECT M.* + FROM mangas M + LEFT JOIN track_dupes D + ON D.manga_id = _id WHERE favorite = 1 AND _id != :id - AND lower(title) LIKE '%' || lower(:title) || '%' + AND (lower(title) LIKE '%' || lower(:title) || '%' OR D.manga_id IS NOT NULL) ), chapter_counts AS ( SELECT