Skip to content

Conversation

EngincanV
Copy link
Member

This pull request refactors and improves the filtering logic in the EfCoreBlogPostRepository for both the GetCountAsync and GetListAsync methods. The main focus is on making the filtering for tag and favorite user IDs more robust and efficient, as well as simplifying the code by removing unnecessary variables and checks.

Filtering and Query Improvements:

  • Updated the filtering logic for tagId and favoriteUserId to ensure only valid GUIDs are used, preventing potential runtime errors from invalid IDs. Now, the code filters and parses IDs in one step using Where(x => Guid.TryParse(x, out _)).Select(Guid.Parse).ToList(). [1] [2]
  • Changed the default values for filtered entity ID lists to empty lists ([]) instead of null, and updated the query conditions to check for .Count > 0 instead of null checks. This simplifies the logic and avoids null reference issues. [1] [2]

Code Simplification:

  • Removed unused variables and redundant code, such as the entityIdFilters variable and unnecessary calls to ToString() on GUIDs in query filters. [1] [2]
  • Streamlined the return statement in GetCountAsync by returning the result of CountAsync directly.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors the filtering logic in the EfCoreBlogPostRepository to improve robustness and efficiency when handling tag and favorite user ID filtering for blog posts.

  • Implements safer GUID parsing with validation using Guid.TryParse before conversion
  • Replaces null checks with empty list initialization and count-based conditions
  • Removes redundant code and unused variables to simplify the implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@EngincanV EngincanV requested a review from oykuermann August 27, 2025 10:59
oykuermann

This comment was marked as resolved.

Refactored tag and favorite user filtering logic in both EfCore and MongoDB blog post repositories to handle empty filter results and cancellation tokens more robustly. Updated BlogPostPublicAppService to pass favoriteUserId to GetCountAsync for accurate paging. Adjusted blog index view to improve favorite filter button visibility and logic.
@EngincanV EngincanV requested a review from oykuermann August 29, 2025 09:37
@oykuermann oykuermann merged commit 7bd9187 into rel-9.3 Aug 29, 2025
3 checks passed
@oykuermann oykuermann deleted the EngincanV/cms-fix-blogposts branch August 29, 2025 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants