fix(history): count distinct new chapter numbers, authoritative on detail
new_chapters_count over-counted when scanlations share a chapter number ((manga_id, number) is non-unique, migration 0013): COUNT(*) tallied rows, so duplicate-numbered chapters inflated the badge. Switch both the list and per-manga read-progress queries to COUNT(DISTINCT number), and drop the dead COALESCE (an empty set counts as 0, and the NULL-number case is handled by the predicate). Fix the misleading comment. Expose new_chapters_count on GET /me/read-progress/:manga_id and drive the detail page's "N new" badge from it, instead of recomputing over the paginated chapter list — which under-counted series past 50 chapters and disagreed with the homepage shelf. Read markers stay client-side over the loaded chapters and are documented as by-number (all we persist). Adds duplicate-scanlation tests at both endpoints. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -79,6 +79,10 @@ export type ReadProgressForManga = {
|
||||
chapter_number: number | null;
|
||||
page: number;
|
||||
updated_at: string;
|
||||
/** Distinct chapter numbers past the last-read chapter — the
|
||||
* authoritative "new since last read" count (over all chapters, not the
|
||||
* detail page's paginated list). `0` when caught up / position unknown. */
|
||||
new_chapters_count: number;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user