Fix stale replyCount in /groups/-/topics due to Redis caching#1624
Closed
Fix stale replyCount in /groups/-/topics due to Redis caching#1624
Conversation
…om Redis cache The /groups/-/topics endpoint was using fetchGroupTopicsByIDs() which caches topic data in Redis with a 24h TTL. This caused replyCount to return stale values (often 0) because cached data didn't reflect new replies. Replace the cached fetcher with a direct DB query, matching the approach already used by /groups/:groupName/topics. Agent-Logs-Url: https://github.com/bangumi/server-private/sessions/104d44e0-80de-476f-8c8a-0e9b751b76aa
Copilot
AI
changed the title
[WIP] Fix replyCount field returning 0 in topics API
Fix stale replyCount in /groups/-/topics due to Redis caching
Apr 6, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1624 +/- ##
==========================================
- Coverage 57.29% 57.05% -0.24%
==========================================
Files 151 151
Lines 6718 6721 +3
Branches 1392 1392
==========================================
- Hits 3849 3835 -14
- Misses 2203 2219 +16
- Partials 666 667 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
/groups/-/topicsreturnsreplyCount: 0for most topics because it fetches topic data viafetchGroupTopicsByIDs(), which caches in Redis with a 24h TTL. Reply counts go stale immediately after caching.The sibling endpoint
/groups/:groupName/topicsdoesn't have this bug — it queries the DB directly.fetcher.fetchGroupTopicsByIDs(tids)with a direct DB query +convert.toGroupTopic(), consistent with how/groups/:groupName/topicsalready works