feat(community): enrich feed & post-detail responses#57
Merged
Conversation
…ty counters Feed endpoint: - Add DownvoteCount, TopicNameAr/En, IsExpert, IsWatchlisted, VoteStatus to CommunityFeedItemDto - Add MostCommented sort (PostFeedSort = 3) ordered by CommentsCount DESC - Add PostType filter (Info/Question/Poll) to ListCommunityFeedQuery; bypasses Redis fast-path Get post by id: - Replace flat author fields with nested PostAuthorDto (Id, Name, AvatarUrl, IsExpert, PostsCount, FollowerCount) - Add TopicNameAr/En, IsWatchlisted, VoteStatus to PostDetailDto - Rewrite handler as a single JOIN query (one SQL round trip); align with Response<T> + MessageFactory User activity counters: - Add PostsCount and CommentsCount to User domain model with Increment/Decrement methods - Add EF configuration (DEFAULT 0) and migration AddUserActivityCounters - Maintain PostsCount in PublishPostCommandHandler and SoftDeletePostCommandHandler - Maintain CommentsCount in CreateReplyCommandHandler and SoftDeleteReplyCommandHandler MessageFactory alignment: - Migrate GetMyFollows, ListPublicPostReplies, ListPublicPostsInTopic handlers to Response<T> - Fix four endpoints still using manual Results.Ok/NotFound to use ToHttpResult()
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.
Summary
CommunityFeedItemDtonow includesDownvoteCount,TopicNameAr/En,IsExpert,IsWatchlisted, andVoteStatus(-1/0/1); all user-specific flags are populated from the current user's JWT and fall back to neutral defaults for anonymous requestsGET /api/community/posts/{id}returns a newPostDetailDtowith a nestedPostAuthorDto(id, name, avatar, expert flag, posts count, follower count) plus topic names and user-specific flags; handler rewritten as a single JOIN query (one SQL round trip) and aligned withResponse<T>+MessageFactoryPostsCountandCommentsCountto theUseraggregate (same denormalized pattern asPost); maintained atomically inPublishPost,SoftDeletePost,CreateReply, andSoftDeleteReplyhandlers; migrationAddUserActivityCountersadds both columns asint NOT NULL DEFAULT 0MostCommentedsort option (PostFeedSort = 3); new optionalPostTypefilter (Info/Question/Poll);PostTypefilter bypasses the Redis fast-path to SQLGetMyFollows,ListPublicPostReplies, andListPublicPostsInTopichandlers from raw return types toResponse<T>; fix four endpoints that were callingResults.Ok/NotFoundmanually to useToHttpResult()Test plan
GET /api/community/feed— anonymous request returns feed withtopicNameAr/En,downvoteCount,isExpert,isWatchlisted=false,voteStatus=0GET /api/community/feedwith JWT —isWatchlistedandvoteStatusreflect the authenticated user's stateGET /api/community/feed?sort=3— results ordered bycommentsCountdescendingGET /api/community/feed?postType=1— only Question posts returnedGET /api/community/posts/{id}— response shape has nestedauthorobject,topicNameAr/En,isWatchlisted,voteStatus; 404 returns standard error envelopepostsCountincrements; soft-delete it → decrementscommentsCountincrements; soft-delete the reply → decrementsGET /api/community/topics/{slug},/topics/{id}/posts,/posts/{id}/replies,/api/me/follows— all return standardResponse<T>envelope (not raw JSON)