refactor: optimize history module architecture and fix pagination#2189
Merged
caneppelevitor merged 14 commits intostagefrom Feb 5, 2026
Merged
Conversation
history.controller.ts: - Implemented Thin Controller pattern, delegating orchestration to the service layer. history.service.ts: - Refactored getHistoryParams to support M2M objects, Chatbot strings, and User ObjectIds. - Migrated from .find() to Aggregation Pipeline for complex polymorphic user lookups. - Fixed pagination bug to ensure correct data loading for multiple pages. history.interfaces.ts: - Centralized Query, Response, and Props interfaces historyApi.ts: - Improved nomenclature and added error handling. - Refined type safety for optional parameters. LocalizedDate.tsx: - Improved type safety and added defensive checks for invalid dates. - Removed hydration workarounds in favor of a native i18n implementation. HistoryListItem.tsx: - Applied Static Extraction pattern to display logic for better memory efficiency. - Implemented null-safety handling to prevent UI crashes with malformed data. - Added useMemo for memoization of display names to optimize re-renders.
18 tasks
caneppelevitor
requested changes
Jan 19, 2026
e9801be to
29544fd
Compare
29544fd to
7d558cc
Compare
|
ec18f16 to
9b27640
Compare
caneppelevitor
approved these changes
Feb 5, 2026
Collaborator
|
@LuizFNJ Remember to move the tickets to needs migration |
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.



Description
This PR delivers a major refactor of the History module to support Universal User Tracking (Internal, Chatbot, and M2M) and restores the Pagination system.
Technical Highlights
.find().populate()to a specialized Aggregation Pipeline to allow conditional lookups based on User type (ObjectId vs String/M2M) and to fix pagination metadata.history.controller.tstohistory.service.ts. The controller now acts strictly as an orchestrator, delegating the complexity of polymorphic user identification (Internal vs Chatbot vs M2M) to the service layer.HistoryListItemandLocalizedDatewith safety checks for null values and invalid dates, including the removal of hydration warnings by integrating properly with Next.js i18n.useMemoin list components to optimize long-list rendering and prevent unnecessary re-computations during pagination.historyApi.tsnaming and improved error handling with optional typing (?) for safer, more predictable requests.getDescriptionForHideto prevent runtime crashes when querying hidden or restricted content.Related Ticket #2188, #2069, #2070, #2196
Type of change
Testing
Unit testing scenarios
Developer Checklist
General
console.logor related logging is added.Frontend Changes
Backend Changes
Tests
Test IDs
Merge Request Review Checklist