You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This chore focuses on refactoring the blog service to improve maintainability, reduce redundancy, and ensure consistent response formatting. Key improvements include extracting reusable logic, simplifying search queries, and optimizing how blog data is retrieved and structured.
Motivation
Refactoring is necessary to:
Reduce duplicate logic when fetching blogs.
Improve response consistency for single blog and paginated responses.
Optimize database queries by minimizing redundant user fetch operations.
Enhance maintainability and readability of the blog service.
Proposed Changes
Extracted findBlogById() to avoid repetitive blog fetching logic and improve error handling.
Introduced formatBlogResponse() for consistent single blog response formatting.
Refactored pagination with formatPaginatedResponse() to remove redundant logic.
Optimized blog creation & update by ensuring users are only fetched when necessary.
Simplified search logic with buildWhereClause() for better readability and maintainability.
Expected Outcome
Code is more modular and easier to maintain.
Response formatting is standardized across different endpoints.
Database queries are optimized, reducing unnecessary fetch operations.
The blog service is easier to extend with future features
Acceptance Criteria
findBlogById() is used to fetch blog posts instead of inline queries.
formatBlogResponse() is implemented for single blog responses.
formatPaginatedResponse() handles pagination across the blog service.
Blog creation and updates do not fetch the user unnecessarily.
Searching for blogs uses buildWhereClause() for better structure.
Additional Context
The text was updated successfully, but these errors were encountered:
olugbenga1
changed the title
[CHORE]
[CHORE]refactor(blog-service): extract helper methods for reusability and consistency
Mar 2, 2025
Description
This chore focuses on refactoring the blog service to improve maintainability, reduce redundancy, and ensure consistent response formatting. Key improvements include extracting reusable logic, simplifying search queries, and optimizing how blog data is retrieved and structured.
Motivation
Refactoring is necessary to:
Proposed Changes
Expected Outcome
Acceptance Criteria
Additional Context
The text was updated successfully, but these errors were encountered: