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.
This pull request refactors multiple controllers in the codebase to streamline query execution and reduce redundancy. It introduces a generic report controller factory for handling similar operations across different data types and replaces custom query handling logic with shared utilities. The changes improve maintainability by consolidating repetitive code into reusable components.
Consolidation of Controllers:
createReportController
insrc/controllers/reportController.js
to handle common functionality foradoption
,pageWeight
,lighthouse
, andcore_web_vitals
data. This eliminates the need for individual implementations of these controllers.Refactoring Controllers to Use Shared Utilities:
listCategories
insrc/controllers/categoriesController.js
to useexecuteQuery
andvalidateArrayParameter
utilities, simplifying query building and data processing.listGeos
insrc/controllers/geosController.js
to use theexecuteQuery
utility, removing custom cache handling logic.listRanks
insrc/controllers/ranksController.js
to use theexecuteQuery
utility, streamlining query execution.Removal of Redundant Code:
listAdoptionData
,listPageWeightData
,listLighthouseData
, andlistCWVTechData
in their respective files (adoptionController.js
,pageWeightController.js
,lighthouseController.js
,cwvtechController.js
) as they are now handled by the generic report controller. [1] [2] [3] [4]