Closed RamRamez closed 2 weeks ago
The recent refactoring focuses on simplifying and consolidating the logic related to QF round statistics within the codebase. Functions were updated to accept QfRound
objects directly instead of specific parameters, merged related functionalities into single functions, and adjusted test cases accordingly. These changes enhance code maintainability and clarity by reducing redundancy and simplifying parameter handling.
Files | Summary |
---|---|
src/repositories/donationRepository.ts |
Refactored getProjectQfRoundStats to accept a QfRound object. |
src/repositories/qfRoundRepository.ts |
Merged and refactored statistic functions into getQfRoundStats which now accepts a QfRound object. |
src/repositories/qfRoundRepository.test.ts |
Updated test cases to match the new getQfRoundStats function and removed old functions. |
src/repositories/donationRepository.test.ts |
Replaced qfRoundId parameter with qfRound in getProjectQfRoundStats function calls. |
src/resolvers/qfRoundResolver.ts |
Replaced individual donor and donation calls with a unified getQfRoundStats function call. |
src/services/projectService.ts |
Updated updateProjectStatistics to pass activeQfRound object instead of specific parameters. |
In the fields of code, where logic thrives, A rabbit dances, simplifying lives. Refactoring functions, merging in glee, With QfRounds in hand, stats now set free. Tests and resolvers, all joined in the dance, Code's harmony enhanced with each prance. 🐇✨
src/repositories/qfRoundRepository.ts (2)
`208-232`: Refactor `getQfRoundStats` to combine unique donor and total donation calculations. This refactoring centralizes the handling of QfRound statistics, making the code cleaner and more maintainable. However, ensure that all dependent code correctly handles the new function signature and return type. --- `225-225`: Good use of caching to enhance performance. The caching strategy is well-implemented, using the QfRound ID to create a unique cache key, which helps in reducing database load by avoiding repeated calculations for the same round.
Summary by CodeRabbit
Refactor
QfRound
objects instead of separate parameters, enhancing code maintainability.Tests