fix(bookmark): include bookmarked articles in the saved list - #219
Open
aquie00t wants to merge 1 commit into
Open
fix(bookmark): include bookmarked articles in the saved list#219aquie00t wants to merge 1 commit into
aquie00t wants to merge 1 commit into
Conversation
Article bookmarks were write-only. POST /articles/:id/bookmark persisted a row to article_bookmarks and the article detail endpoint reported isBookmarked correctly, but GET /posts/bookmarks never queried that table, so a saved article was unreachable from every read path. Articles live in their own table rather than under Post, so the existing post query could not see them. GetArticlesParams.savedByUserId and its Prisma filter (where.bookmarks) already existed; nothing called them. - GetBookmarksUseCase takes articleRepository and fetches bookmarked articles alongside posts and comments - the response carries data.articles and meta.articleTotal; articles are summaries because a body can be 100 KB of markdown - unit tests cover the new dependency and the savedByUserId hand-off No DI change was needed: awilix runs in CLASSIC mode and resolves by constructor parameter name, which already matches the registry key. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019YbEuSAiGYLZmwvhcrov4g
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.
Problem
Saving an article did nothing visible.
POST /articles/:id/bookmarkreturned 200 and the row landed inarticle_bookmarks—GET /articles/:slugeven reportedisBookmarked: true— but the article never appeared in the saved list.Reproduced against a running instance:
The response had no
articleskey at all.Cause
GetBookmarksUseCaseonly ever asked two sources:Articles live in their own table rather than under
Post, so the post query cannot see them. No other endpoint filled the gap either:GET /articleshas nobookmarkedfilter and/articles/mereturns articles you wrote, filtered by status. Article bookmarks were write-only — reachable by no read path.Fix
The plumbing already existed and simply was not called:
GetArticlesParams.savedByUserId— already declared on the portprisma-article.repository.ts:178—where.bookmarks = { some: { userId: savedByUserId } }— already implementedSo this wires up what was there rather than adding a new query.
GetBookmarksUseCasetakesarticleRepositoryand fetches bookmarked articles alongside posts and comments, in the samePromise.alldata.articlesandmeta.articleTotalArticleSummarySchema, not the full item — a body can be 100 KB of markdown and a saved list renders cardsNo DI registration change was needed: awilix runs in
CLASSICmode and resolves by constructor parameter name, which already matches thearticleRepositoryregistry key.Verification
Add/remove round-trip against a live instance:
pnpm test:unit— 764/764 passing (5 existing tests adapted to the new dependency, 1 added covering thesavedByUserIdhand-off).pnpm lintandpnpm format:checkclean.Notes for reviewers
data.articlesandmeta.articleTotalare additive, so existing clients keep working, but the saved-list screen needs to render the new field before this is visible to users.page=2is passed to each of the three queries separately, matching the existing posts/comments behaviour. A single merged, chronologically sorted feed would be a separate design decision, not a bug fix.🤖 Generated with Claude Code
https://claude.ai/code/session_019YbEuSAiGYLZmwvhcrov4g