Skip to content

fix: order and page the user feed by article, newest first - #1259

Open
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/task-25-feed-order-pagination
Open

devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/task-25-feed-order-pagination

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

GET /articles/feed returned the wrong page: findArticlesOfAuthors applied limit offset, n to the article × tag join rows and had no order by. With two tags per article, limit=10 returned 5 articles, oldest first, while articlesCount counted all of them, so the Angular "Your Feed" showed only the oldest five posts and never a second page.

The query now pages article ids first, newest first, then loads them, like queryArticles does for the global list:

where A.id in (select FA.id from (
  select id from articles where user_id in (...) order by created_at desc limit #{offset}, #{limit}
) FA)
order by A.created_at desc

Found while running the Angular app against the #1258 backend (angular-realworld-example-app#85). The mapper is unchanged by #1258, so this targets master and merges on its own on either side of it.

Added ArticleQueryServiceTest.should_page_user_feed_by_article_newest_first (passes with ./gradlew test --tests ArticleQueryServiceTest on JDK 11). spotlessJavaCheck on master already fails on DefaultJwtServiceTest.java, which this PR does not touch.


Migration Engineer opened this PR for Matthew
Implemented in session Wire Angular RealWorld app to Boot 3 backend
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Custom reviewers

  • 🧪 Test 2 reviewer: no findings · View
  • 🚩 TD Enterprise Architecture: no findings · View
  • 👁️ TD Information Security: no findings · View
  • 🧠 TD French Language (Bill 96): no findings · View
  • ⏱️ TD API Contracts: no findings · View

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Author

I added 4 tests for the feed paging change in a separate test PR, but couldn't run them: Gradle couldn't download dependencies on my machine. The test file compiles and is formatted correctly. Someone still needs to run ./gradlew spotlessJavaCheck test on PR #1261 before merging it.

Maven Central returned HTTP 429, and the mirror hosts this machine is set up to use (maven-central.storage-download.googleapis.com, dl.google.com) aren't on the network allowlist. I requested access to them but it hasn't been approved.

Review of #1259

  • suggestion: Articles with the same created_at have no fixed order, so offset paging can repeat or skip them across pages. Add id desc as a tiebreaker to both order by clauses (inner and outer).
  • question (outside this diff): The cursor feed query used by GraphQL, findArticlesOfAuthorsWithCursor, has the bug this PR fixes. Its limit counts joined tag rows, not articles, so pages can come back short or with incomplete tag lists. It probably needs the same subquery fix in a follow-up.
  • The select FA.id from (...) FA wrapper and the newest-first ordering look correct, and the count query doesn't need to change.

Gaps filled in ArticleQueryServiceTest

  • Two followed authors with interleaved timestamps: pages are ordered by time across authors.
  • Articles with 0 and 4 tags: the page limit counts articles, not tag rows, and tag lists stay complete.
  • Articles from unfollowed users and from the viewer are left out of the page and the count.
  • An offset past the end returns an empty page, and the count is still correct.

I didn't approve, merge, or push to the author's branch.

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.

0 participants