Closed ae2079 closed 1 week ago
The recent changes involve replacing the fromOptimismOnly
boolean parameter with a more flexible networkId
numeric parameter across various parts of the codebase. This shift, applied to donation and project repositories, resolvers, and test GraphQL queries, enables filtering by specific network IDs instead of using a simpler optimism flag. This update increases the granularity and flexibility of network-based queries and functionality.
Files | Change Summary |
---|---|
src/repositories/donationRepository.ts | Replaced fromOptimismOnly parameter with networkId in functions for calculating donation metrics. |
src/repositories/projectRepository.ts | Replaced includesOptimism parameter with networkId in functions for retrieving project metrics. |
src/resolvers/donationResolver.ts | Updated method arguments to use networkId instead of fromOptimismOnly for filtering donations by network. |
src/resolvers/projectResolver.ts | Replaced includesOptimism parameter with networkId for project-related methods in the resolver. |
test/graphqlQueries.ts | Renamed query parameters from includesOptimism and fromOptimismOnly to networkId in multiple GraphQL queries used for testing. |
Amidst the networks old and new,
Where donations sparkle, in vibrant hue,
No more flags to check Optimism's cheer,
A numeric path, now crystal clear.
Projects thrive and totals rise,
WithnetworkId
, we’re wise,
In data's scope, joy multiplies.
src/resolvers/donationResolver.ts
[error] 231-231: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 232-232: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 265-265: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 266-266: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 267-267: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 268-268: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 319-319: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 320-320: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 321-321: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 322-322: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 356-356: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 357-357: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 358-358: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 359-359: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 397-397: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 405-405: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 406-406: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 407-407: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 433-433: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 434-434: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file.src/resolvers/projectResolver.ts
[error] 653-653: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 655-655: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 689-689: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 705-705: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 719-719: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 795-795: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 797-797: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 831-831: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 832-832: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 834-834: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 835-835: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 910-910: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 911-911: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 913-913: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 914-914: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 1047-1047: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 1048-1048: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 1049-1049: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 1208-1208: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file. --- [error] 1209-1209: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file.
src/resolvers/donationResolver.ts (4)
`297-301`: **Conditional query construction** The conditional logic for constructing the query based on `networkId` is well implemented. It ensures that the `networkId` filter is correctly applied whether other date filters are present or not. This is crucial for maintaining the correct logic flow and ensuring accurate data retrieval based on the network ID. --- Line range hint `321-339`: **Ensure consistent error handling** The method `donationsTotalUsdPerDate` correctly uses the `networkId` parameter to filter donations. However, ensure that error handling is consistent across all query methods. It's good practice to log and rethrow the error, as done here, to maintain transparency in error management. --- `267-267`: **Correct decorator usage for method parameter** The `@Arg('networkId', { nullable: true })` decorator is used correctly here to define a method parameter. However, the static analysis tool flagged an error about decorators not being valid here. This might be a configuration issue or a false positive, as decorators are commonly used in `type-graphql`.Verification successful
--- **Parameter decorator configuration is correct** The `tsconfig.json` file contains the `experimentalDecorators` setting enabled, which supports the usage of decorators like `@Arg` in `type-graphql`. - `tsconfig.json`: ```json "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */ ``` This confirms that the `@Arg` decorator is configured correctly in the TypeScript setup.Scripts executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Check if parameter decorators are enabled in the TypeScript configuration. cat tsconfig.json | jq '.compilerOptions.experimentalDecorators' ``` Length of output: 121 --- --- Script: ```shell #!/bin/bash # Locate the tsconfig.json file and validate its JSON structure fd --type f --name tsconfig.json --exec jq empty {} # Check the experimentalDecorators setting in the tsconfig.json file fd --type f --name tsconfig.json --exec jq '.compilerOptions.experimentalDecorators' {} ``` Length of output: 647 --- --- Script: ```shell #!/bin/bash # Locate the tsconfig.json file fd tsconfig.json # Check the experimentalDecorators setting in the tsconfig.json file jq '.compilerOptions.experimentalDecorators' tsconfig.json ``` Length of output: 148 --- --- Script: ```shell #!/bin/bash # Output the contents of the tsconfig.json file to inspect for errors cat tsconfig.json ``` Length of output: 5148--- Line range hint `358-376`: **Check for correct implementation of network filtering** The method `totalDonationsNumberPerDate` includes changes for `networkId` handling. It's important to verify that the implementation aligns with the intended business logic, especially when handling conditional queries based on network ID.Tools
Biome
[error] 267-267: Decorators are not valid here. (parse) Decorators are only valid on class declarations, class expressions, and class methods. You can enable parameter decorators by setting the `unsafeParameterDecoratorsEnabled` option to `true` in your configuration file.Verification successful
--- **Check for correct implementation of network filtering** The `totalDonationsNumberPerDate` method in `src/resolvers/donationResolver.ts` does indeed handle the `networkId` parameter. It correctly passes `networkId` to the `donationsNumberPerDateRange` and `donationsTotalNumberPerDateRangeByMonth` functions, ensuring that network filtering is applied as expected. - **File**: `src/resolvers/donationResolver.ts` - **Method**: `totalDonationsNumberPerDate` - **Lines**: 366-379Scripts executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify the correct implementation of network filtering in the donation queries. ast-grep --lang typescript --pattern $'class DonationResolver { $$$ totalDonationsNumberPerDate($_, $_, $_, $_) { $$$ } $$$ }' ``` Length of output: 141 --- --- Script: ```shell #!/bin/bash # Search for the `totalDonationsNumberPerDate` method in the entire codebase. rg 'totalDonationsNumberPerDate' ``` Length of output: 848 --- Script: ```shell #!/bin/bash # Verify the handling of `networkId` within the `totalDonationsNumberPerDate` method. ast-grep --lang typescript --pattern $'function totalDonationsNumberPerDate($_, $_, $networkId, $_) { $$$ }' ``` Length of output: 111 --- --- Script: ```shell #!/bin/bash # Display the implementation of the `totalDonationsNumberPerDate` method in `src/resolvers/donationResolver.ts`. ast-grep --lang typescript --pattern $'async totalDonationsNumberPerDate($_, $_, $_, $_) { $$$ }' src/resolvers/donationResolver.ts ``` Length of output: 616 --- --- Script: ```shell #!/bin/bash # Display the implementation of the `totalDonationsNumberPerDate` method in `src/resolvers/donationResolver.ts` with corrected pattern. ast-grep --lang typescript --pattern $'async totalDonationsNumberPerDate($_, $_, $_, $_): Promise<$_> { $$$ }' src/resolvers/donationResolver.ts ``` Length of output: 642 --- --- Script: ```shell #!/bin/bash # Display the implementation of the `totalDonationsNumberPerDate` method in `src/resolvers/donationResolver.ts` using `cat` and `awk`. awk '/async totalDonationsNumberPerDate/,/^\}/' src/resolvers/donationResolver.ts ``` Length of output: 20192src/resolvers/projectResolver.ts (2)
Line range hint `1294-1311`: **Updated method parameters to use `networkId`.** The changes correctly replace the `includesOptimism` boolean with the more flexible `networkId` integer. This allows for more granular control over which network's data is queried, which aligns with the PR's objectives. --- Line range hint `653-653`: **Invalid use of decorators reported by static analysis.** The static analysis tool has identified multiple lines where decorators are incorrectly applied. This issue typically arises due to a misconfiguration in the TypeScript compiler options. Ensure that the `experimentalDecorators` and `emitDecoratorMetadata` options are enabled in your `tsconfig.json`. If these options are already enabled, this may be a false positive from the static analysis tool. Also applies to: 655-655, 689-689, 705-705, 719-719, 795-795, 797-797, 831-831, 832-832, 834-834, 835-835, 910-910, 911-911, 913-913, 914-914, 1047-1047, 1048-1048, 1049-1049, 1208-1208, 1209-1209
related to this issue: https://github.com/Giveth/analytics-dashboard/issues/9 and should be merge before this PR: https://github.com/Giveth/analytics-dashboard/pull/12
Summary by CodeRabbit
New Features
networkId
parameter for filtering donations and projects based on a specific network ID.Refactor
fromOptimismOnly
andincludesOptimism
withnetworkId
across various donation and project-related functions.Tests
networkId
instead of the previous boolean parameters.