-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onlyEndaement option added to donationResolvers to get only endaoment… #1796
onlyEndaement option added to donationResolvers to get only endaoment… #1796
Conversation
WalkthroughThe changes introduce a new optional parameter, Changes
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
src/resolvers/donationResolver.ts (1)
339-343
: LGTM with a suggestion!The if block correctly filters donations based on the
onlyEndaoment
parameter.Suggestion: Consider defining a constant for the string literal
'endaoment'
to improve readability and maintainability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @HrithikSampson
LGTM
…ytics_track_donation_statistics_for_endaoment_projects pull staging branch
…ytics_track_donation_statistics_for_endaoment_projects Update Branch
@HrithikSampson |
…h the pre-existing test cases
Hi @ae2079 , The test cases have passed, the Second User from the SEED Data was being used to donate to a project and the last donation made was the fifth donation of the SEED Data. Since I used the second user in my code to make donations it was failing, but now after changing it to a new user to make the donations it is passing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- src/repositories/donationRepository.test.ts (3 hunks)
- src/repositories/donationRepository.ts (13 hunks)
- src/resolvers/donationResolver.test.ts (4 hunks)
- src/resolvers/donationResolver.ts (8 hunks)
- test/graphqlQueries.ts (4 hunks)
Additional comments not posted (36)
src/repositories/donationRepository.ts (6)
Line range hint
181-214
: LGTM!The changes introduce a new
onlyEndaoment
filter, enabling the function to retrieve donations specific to Endaoment organizations. The query logic is updated to conditionally join theproject
andorganization
tables based on the filter combination, ensuring optimal performance. The cache key is also correctly updated to maintain the integrity of cached results.
Line range hint
233-269
: LGTM!The changes introduce a new
onlyEndaoment
filter, enabling the function to retrieve donations per month specific to Endaoment organizations. The query logic is updated to conditionally join theproject
andorganization
tables based on the filter combination, ensuring optimal performance. The cache key is also correctly updated to maintain the integrity of cached results.
Line range hint
290-323
: LGTM!The changes introduce a new
onlyEndaoment
filter, enabling the function to retrieve the total number of donations specific to Endaoment organizations. The query logic is updated to conditionally join theproject
andorganization
tables based on the filter combination, ensuring optimal performance. The cache key is also correctly updated to maintain the integrity of cached results.
Line range hint
342-377
: LGTM!The changes introduce a new
onlyEndaoment
filter, enabling the function to retrieve the total number of donations per month specific to Endaoment organizations. The query logic is updated to conditionally join theproject
andorganization
tables based on the filter combination, ensuring optimal performance. The cache key is also correctly updated to maintain the integrity of cached results.
Line range hint
397-423
: LGTM!The changes introduce a new
onlyEndaoment
filter, enabling the function to retrieve the count of unique donors specific to Endaoment organizations. The query logic is updated to join theproject
andorganization
tables whenonlyEndaoment
is true, allowing for filtering based on the organization label. The cache key is also correctly updated to maintain the integrity of cached results.
Line range hint
473-499
: LGTM!The changes introduce a new
onlyEndaoment
filter, enabling the function to retrieve the count of unique donors per month and year specific to Endaoment organizations. The query logic is updated to join theproject
andorganization
tables whenonlyEndaoment
is true, allowing for filtering based on the organization label. The cache key is also correctly updated to maintain the integrity of cached results.src/resolvers/donationResolver.ts (5)
75-75
: LGTM!The import statement for
ORGANIZATION_LABELS
is syntactically correct and likely used in the subsequent code changes.
360-366
: LGTM!The query modification within the if block correctly filters the donations based on the "Endaoment" organization label when the
onlyEndaoment
parameter is true. The usage of theORGANIZATION_LABELS.ENDAOMENT
constant ensures the correct label is matched.
319-319
: Verify the usage of the newonlyEndaoment
parameter.The addition of the optional
onlyEndaoment
parameter to thetotalDonationsPerCategory
method is syntactically correct. Ensure that this parameter is properly handled within the method implementation and any relevant code paths.Run the following script to verify the parameter usage:
381-381
: Verify the usage of the newonlyEndaoment
parameter.The addition of the optional
onlyEndaoment
parameter to thedonationsTotalUsdPerDate
method is syntactically correct. Ensure that this parameter is properly passed to the relevant repository methods (donationsTotalAmountPerDateRange
anddonationsTotalAmountPerDateRangeByMonth
) and handled correctly within those methods.Run the following script to verify the parameter usage:
Verification successful
Verification successful:
onlyEndaoment
parameter is correctly implemented and used.The
onlyEndaoment
parameter has been properly added to thedonationsTotalUsdPerDate
method insrc/resolvers/donationResolver.ts
. It is correctly used within the method body and passed to relevant repository methods. The parameter is also handled in the repository layer (src/repositories/donationRepository.ts
) in multiple methods, indicating proper implementation throughout the codebase. Additionally, test files have been updated to include the new parameter, suggesting that the change has been thoroughly tested.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `onlyEndaoment` parameter in `donationsTotalUsdPerDate`. # Test: Search for the parameter usage. Expect: Occurrences within the method implementation and relevant repository methods. rg --type typescript -A 5 $'onlyEndaoment\?\: boolean'Length of output: 159
Script:
#!/bin/bash # Description: Verify the usage of the `onlyEndaoment` parameter in `donationsTotalUsdPerDate`. # Find the method declaration and its body echo "Method declaration and body:" ast-grep --lang typescript --pattern 'async donationsTotalUsdPerDate($$$) { $$$ }' # Search for potential usages of the parameter echo -e "\nPotential usages of onlyEndaoment:" rg --type typescript -i 'onlyendaoment'Length of output: 781
Script:
#!/bin/bash # Description: Verify the existence and usage of the `onlyEndaoment` parameter in `donationsTotalUsdPerDate`. # Find the method signature echo "Method signature:" ast-grep --lang typescript --pattern 'donationsTotalUsdPerDate($_)' # Search for the method name echo -e "\nMethod name occurrences:" rg --type ts 'donationsTotalUsdPerDate' # Search for potential usages of the parameter echo -e "\nPotential usages of onlyEndaoment:" rg --type ts -i 'onlyendaoment'Length of output: 4390
513-513
: Verify the usage of the newonlyEndaoment
parameter.The addition of the optional
onlyEndaoment
parameter to thetotalDonorsCountPerDate
method is syntactically correct. Ensure that this parameter is properly passed to the relevant repository methods (donorsCountPerDate
anddonorsCountPerDateByMonthAndYear
) and handled correctly within those methods.Run the following script to verify the parameter usage:
Verification successful
Verification of
onlyEndaoment
parameter usage successful.The
onlyEndaoment
parameter has been properly implemented and is being used correctly in the codebase. It is present in multiple functions includingdonorsCountPerDate
,donorsCountPerDateByMonthAndYear
, andtotalDonorsCountPerDate
. The parameter is consistently used as an optional boolean to filter donations for Endaoment projects when set to true. The implementation appears to be correct and aligns with the intended functionality.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `onlyEndaoment` parameter in `totalDonorsCountPerDate`. # Test: Search for the parameter usage. Expect: Occurrences within the method implementation and relevant repository methods. rg --type typescript -A 5 $'onlyEndaoment\?\: boolean'Length of output: 159
Script:
#!/bin/bash # Description: Verify the usage of the `onlyEndaoment` parameter in `totalDonorsCountPerDate`. # Search for the parameter declaration (both correct and misspelled versions) echo "Searching for parameter declaration:" rg --type typescript -A 5 'only(Endaoment|Endowment)\?\s*:\s*boolean' # Find the method implementation and check for parameter usage echo "Searching for method implementation:" ast-grep --lang typescript --pattern $'@Query(() => [DonorCountPerDateType]) async totalDonorsCountPerDate( $$$ only(Endaoment|Endowment)\?: boolean, $$$ ) { $$$ }' # Search for usage in related repository methods echo "Searching for usage in repository methods:" rg --type typescript -A 10 'donorsCountPerDate|donorsCountPerDateByMonthAndYear'Length of output: 1212
Script:
#!/bin/bash # Description: Verify the usage of the `onlyEndaoment` parameter in `totalDonorsCountPerDate`. # Search for the parameter declaration echo "Searching for parameter declaration:" fd -e ts -x rg -A 5 'only(Endaoment|Endowment)\?:\s*boolean' # Find the method implementation echo "Searching for method implementation:" ast-grep --lang typescript --pattern 'async totalDonorsCountPerDate($$$) {' # Search for parameter usage in the method body echo "Searching for parameter usage in method body:" fd -e ts -x rg -A 10 'totalDonorsCountPerDate.*\{' -p1 | rg 'only(Endaoment|Endowment)' # Search for usage in related repository methods echo "Searching for usage in repository methods:" fd -e ts -x rg -A 10 'donorsCountPerDate|donorsCountPerDateByMonthAndYear'Length of output: 270893
test/graphqlQueries.ts (4)
573-580
: LGTM!The new optional parameter
$onlyEndaoment
is correctly added to thefetchTotalDonationsPerCategoryPerDate
query and passed to thetotalDonationsPerCategory
function. This allows filtering donations from only Endaoment organizations, enhancing the query functionality without introducing breaking changes.
616-622
: Looks good!The
$onlyEndaoment
parameter is properly added to thefetchTotalDonors
query and passed to thetotalDonorsCountPerDate
function. This allows filtering total donors from only Endaoment organizations, enhancing the query functionality without causing any breaking changes.
639-646
: Approved!The
$onlyEndaoment
parameter is correctly added to thefetchTotalDonationsUsdAmount
query and passed to thedonationsTotalUsdPerDate
function. This allows filtering total donations USD amount from only Endaoment organizations, enhancing the query functionality without introducing any breaking changes.
659-678
: Changes look great!The
$onlyEndaoment
parameter is properly added to thefetchTotalDonationsNumberPerDateRange
query and passed to thetotalDonationsNumberPerDate
function. This allows filtering total donations number per date range from only Endaoment organizations, enhancing the query functionality without causing any breaking changes.The reformatting of the query and function arguments with line breaks and indentation improves readability without altering the functionality.
src/repositories/donationRepository.test.ts (11)
99-190
: LGTM!The test case looks good. It correctly sets up the test data and makes the appropriate assertions to verify the
donorsCountPerDateByMonthAndYear
function behavior for all projects vs endaoment projects over a 3 month period.
192-237
: LGTM!The test case looks good. It correctly sets up the test data and makes the appropriate assertions to verify the
donationsNumberPerDateRange
function behavior for all projects vs endaoment projects on a specific date.
239-334
: LGTM!The test case looks good. It correctly sets up the test data and makes the appropriate assertions to verify the
donationsTotalNumberPerDateRangeByMonth
function behavior for all projects vs endaoment projects over a 3 month period.
336-381
: LGTM!The test case looks good. It correctly sets up the test data and makes the appropriate assertions to verify the
donationsNumberPerDateRange
function behavior for all projects vs endaoment projects on a specific date.
383-490
: LGTM!The test case looks good. It correctly sets up the test data and makes the appropriate assertions to verify the
donationsTotalAmountPerDateRangeByMonth
function behavior for all projects vs endaoment projects over a 3 month period.
492-544
: LGTM!The test case looks good. It correctly sets up the test data and makes the appropriate assertions to verify the
donationsTotalAmountPerDateRange
function behavior for all projects vs endaoment projects on a specific date.
Line range hint
545-583
: LGTM!The test case looks good. It correctly sets up the test data, triggers the
fillQfRoundDonationsUserScores
function by setting the QF round to inactive, and makes the appropriate assertions to verify thatqfRoundUserScore
is populated correctly based on the donation status.
Line range hint
585-686
: LGTM!The test cases look good. They correctly set up the test data, refresh the estimated matching view, and make the appropriate assertions to verify the expected matching distribution behavior based on the number and size of donations to each project.
Line range hint
688-724
: LGTM!The test cases look good. They correctly set up the test data and make the appropriate assertions to verify the expected behavior of the
findDonationsByTransactionId
function, including case-insensitivity and handling of non-existent transaction IDs.
Line range hint
726-772
: LGTM!The test cases look good. They correctly set up the test data and make the appropriate assertions to verify the expected behavior of the
findDonationById
function, including checking for associated project and QF round, and handling of non-existent donation IDs.
Line range hint
774-800
: LGTM!The test case looks good. It correctly sets up the test data, calls the
createDonation
function with the necessary data, and makes the appropriate assertion to verify that the created donation is associated with the correct project.src/resolvers/donationResolver.test.ts (10)
171-276
: Approved: The new test case for endaoment projects looks good!The added test case thoroughly verifies the donation count per category for endaoment projects over a specified time range. It checks the counts before and after adding donations, and also filters for only endaoment projects within the time frame. The implementation looks correct and comprehensive.
330-431
: Approved: The new test case for endaoment projects looks good!The added test case thoroughly verifies the total donation count for endaoment projects over a specified time range. It checks the total count, the count for only verified donations, and the count for verified endaoment donations. The implementation looks correct and comprehensive.
519-639
: Approved: The new test case for endaoment projects looks good!The added test case thoroughly verifies the unique donor count for endaoment projects over a specified time range. It checks the total unique count for all projects and for only endaoment projects, handling anonymous donations separately. The implementation looks correct and comprehensive.
Line range hint
641-679
: LGTM!The test case correctly verifies the new donor count and their total donation over a specified time range. It sets up the test data appropriately and makes the right assertions.
Line range hint
681-806
: Approved: The test cases fordoesDonatedToProjectInQfRound
query look good!The test cases cover various scenarios thoroughly:
- When there is a verified donation in the specified QF round
- When the donation is non-verified
- When the projectId, qfRoundId, or userId is invalid
The test case implementations look correct and make the right assertions.
960-1031
: Approved: The new test case for endaoment projects looks good!The added test case thoroughly verifies the total USD amount for donations to endaoment projects over a specified time range. It creates donations to endaoment and non-endaoment projects and checks the total amount and the amount for only endaoment projects. The implementation looks correct and comprehensive.
Line range hint
1033-1222
: LGTM: The test cases fordonations
query look good!The test cases cover various scenarios thoroughly:
- Error handling for invalid fromDate and toDate formats
- Returning results without any time filters
- Returning results with recurring donations joined
- Filtering results by fromDate, toDate, and both
- Including project categories in the returned donations
The test case implementations look correct and make the right assertions.
Line range hint
1224-2591
: Excellent test coverage forcreateDonation
mutation!The test cases are very comprehensive and cover a wide range of scenarios, including:
- Creating donations for different organizations on different networks
- Handling different tokens based on the organization and network
- Extensive error handling for invalid scenarios
- Verifying donation status and segmentNotified after creation
- Saving referrer wallet and handling anonymous donations
- Marking draft donations as matched
- Filling USD value and givback calculations
- Creating donations for active QF rounds
- Creating Solana donations
The test case implementations look thorough, correct, and make the right assertions. Great job with the test coverage!
Line range hint
2593-2686
: LGTM: The test cases fordonationsFromWallets
query look good!The test cases cover the important scenarios:
- Finding donations from the specified wallet address successfully
- Finding donations from the specified wallet address in uppercase successfully
- Finding donations from only the specified wallet address when there are donations from other addresses too
- Returning no donations when there are no donations from the specified wallet address
The test case implementations look correct and make the right assertions.
Line range hint
2688-3021
: Comprehensive test coverage fordonationsByProjectId
query!The test cases cover a range of scenarios, including:
- Filtering donations by QF round
- Sorting donations by different fields in ascending and descending order
- Searching donations by various criteria (user name, amount, currency, toWalletAddress)
- Filtering donations by status and returning all donations when no status filter is provided
- Returning recurringDonationsCount and totalCount correctly
The test case implementations look thorough, correct, and make the right assertions. The test coverage for this query is comprehensive and covers the important scenarios and edge cases. Well done!
@@ -406,6 +418,7 @@ export class DonationResolver { | |||
@Arg('toDate', { nullable: true }) toDate?: string, | |||
@Arg('networkId', { nullable: true }) networkId?: number, | |||
@Arg('onlyVerified', { nullable: true }) onlyVerified?: boolean, | |||
@Arg('onlyEndaoment', { nullable: true }) onlyEndaoment?: boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Incorrect parameter usage and naming issue detected
The onlyEndaoment
parameter has been added to the totalDonationsNumberPerDate
method, but there are some issues:
- The parameter is not being used in the method implementation or passed to the repository methods (
donationsNumberPerDateRange
anddonationsTotalNumberPerDateRangeByMonth
). - There's a typo in the parameter name:
onlyEndaoment
should beonlyEndowment
.
To resolve these issues:
- Correct the parameter name to
onlyEndowment
. - Implement the parameter usage in the
totalDonationsNumberPerDate
method. - Pass the parameter to the relevant repository methods if needed.
Analysis chain
Verify the usage of the new onlyEndaoment
parameter.
The addition of the optional onlyEndaoment
parameter to the totalDonationsNumberPerDate
method is syntactically correct. Ensure that this parameter is properly passed to the relevant repository methods (donationsNumberPerDateRange
and donationsTotalNumberPerDateRangeByMonth
) and handled correctly within those methods.
Run the following script to verify the parameter usage:
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the usage of the `onlyEndaoment` parameter in `totalDonationsNumberPerDate`.
# Test: Search for the parameter usage. Expect: Occurrences within the method implementation and relevant repository methods.
rg --type typescript -A 5 $'onlyEndaoment\?\: boolean'
Length of output: 159
Script:
#!/bin/bash
# Description: Verify the usage of the `onlyEndaoment` parameter in `totalDonationsNumberPerDate`.
# Search for the method implementation and parameter usage
ast-grep --lang typescript --pattern $'@Arg("onlyEndaoment", { nullable: true }) onlyEndaoment\?: boolean,
$$$
async totalDonationsNumberPerDate($$$) {
$$$
}'
# Search for both correct and misspelled parameter usage in the entire codebase
rg --type typescript -i '(onlyendao?wment)'
# Search for related repository method calls
rg --type typescript 'donationsNumberPerDateRange|donationsTotalNumberPerDateRangeByMonth'
Length of output: 927
Script:
#!/bin/bash
# Description: Verify the usage of the `onlyEndaoment` parameter in `totalDonationsNumberPerDate`.
# Search for the parameter declaration
ast-grep --lang typescript --pattern '@Arg("onlyEndaoment", { nullable: true }) onlyEndaoment?: boolean,'
# Search for the method implementation and parameter usage
rg 'async totalDonationsNumberPerDate' -A 10
# Search for both correct and misspelled parameter usage in the entire codebase
rg -i '(onlyendao?wment)'
# Search for related repository method calls
rg 'donationsNumberPerDateRange|donationsTotalNumberPerDateRangeByMonth'
Length of output: 3540
relates to Giveth/analytics-dashboard#13
I have added only Endaoment option to get Donations only from endaoment projects to fetch endaoment project donations when only enldaoment is clicked in analytics dashboard
Summary by CodeRabbit
New Features
Bug Fixes