Skip to content
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

feat: add tacking recurring donations queries #1704

Merged
merged 3 commits into from
Jul 23, 2024

Conversation

Meriem-BM
Copy link
Member

@Meriem-BM Meriem-BM commented Jul 19, 2024

Related to Giveth/analytics-dashboard#22 (comment)

Summary by CodeRabbit

  • New Features

    • Introduced new queries for recurring donations: recurringDonationsCountPerDate and recurringDonationsTotalStreamedUsdPerDate, allowing for detailed data retrieval based on date ranges and verification status.
    • Added functions to handle recurring donation data, enhancing reporting capabilities with counts and totals grouped by date and verification status.
  • Bug Fixes

    • Removed outdated validation for recurring donation stats, streamlining the validation process.
  • Chores

    • Cleaned up unused classes and functions related to the previous recurring donation statistics structure.

Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Walkthrough

The update significantly enhances the RecurringDonationResolver and related services by introducing new GraphQL queries that provide improved granularity and flexibility for recurring donation statistics. The previous singular approach has been replaced with more specific queries for counting donations and calculating total amounts streamed, streamlining data retrieval while simplifying validation by removing outdated components.

Changes

Files Change Summary
src/resolvers/.../recurringDonationResolver.ts, src/services/.../recurringDonationService.ts Removed old classes and queries; introduced new asynchronous functions and queries for recurring donations, enhancing granularity and performance.
test/.../graphqlQueries.ts Replaced old query for fetching donation stats with new queries focused on counting and total USD values.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Resolver
    participant Service
    participant Database

    Client->>Resolver: request recurringDonationsCountPerDate
    Resolver->>Service: call recurringDonationsCountPerDateRange
    Service->>Database: query data
    Database-->>Service: return counts
    Service-->>Resolver: return counts
    Resolver-->>Client: return data
Loading

Poem

🐇 In fields of green, where donations flow,
New queries bloom, like flowers in a row.
Counts and totals, oh what a delight,
Granular insights shining so bright!
Hopping with joy, let’s celebrate,
These changes bring love to our data state! 🌼


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6dec94f and b659c58.

Files selected for processing (2)
  • src/resolvers/recurringDonationResolver.ts (5 hunks)
  • src/services/recurringDonationService.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/services/recurringDonationService.ts
Additional comments not posted (2)
src/resolvers/recurringDonationResolver.ts (2)

709-750: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to recurringDonationsTotalStreamedUsdPerDate match the new signature.

Verification successful

Verified: The function usage matches the new signature.

The code changes are approved, and the function recurringDonationsTotalStreamedUsdPerDate is used correctly in the codebase.

  • test/graphqlQueries.ts: The function call matches the new signature.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `recurringDonationsTotalStreamedUsdPerDate` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type typescript -A 5 $'recurringDonationsTotalStreamedUsdPerDate'

Length of output: 104


Script:

#!/bin/bash
# Description: Verify all function calls to `recurringDonationsTotalStreamedUsdPerDate` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg -A 5 'recurringDonationsTotalStreamedUsdPerDate'

Length of output: 1309


665-707: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to recurringDonationsCountPerDate match the new signature.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Outside diff range, codebase verification and nitpick comments (2)
src/resolvers/recurringDonationResolver.ts (2)

685-718: Ensure date format validation.

The resourcePerDateReportValidator currently validates fromDate and toDate using resourcePerDateRegex, which matches the format YYYY-MM-DD. However, the expected format is YYYYMMDD HH:mm:ss. Please update the regex to match the expected date format.

  • src/utils/validators/graphqlQueryValidators.ts: Update the resourcePerDateRegex to validate YYYYMMDD HH:mm:ss.
Analysis chain

Ensure date format validation.

Ensure that fromDate and toDate are validated to match the expected format YYYYMMDD HH:mm:ss.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `fromDate` and `toDate` are validated to match the expected format.

# Test: Search for usage of `resourcePerDateReportValidator`. Expect: Matches in the query file.
rg --type js --type ts 'resourcePerDateReportValidator'

Length of output: 1056


Script:

#!/bin/bash
# Description: Extract the definition of `resourcePerDateReportValidator` to verify date format validation.

# Extract the definition of `resourcePerDateReportValidator` from the validators file.
rg --type js --type ts --context 10 'resourcePerDateReportValidator' src/utils/validators/graphqlQueryValidators.ts

Length of output: 791


Script:

#!/bin/bash
# Description: Extract the definition of `resourcePerDateRegex` to verify date format validation.

# Extract the definition of `resourcePerDateRegex` from the validators file.
rg --type js --type ts --context 10 'resourcePerDateRegex' src/utils/validators/graphqlQueryValidators.ts

Length of output: 2060


648-683: Ensure date format validation.

The resourcePerDateReportValidator uses a regex pattern that does not match the expected format YYYYMMDD HH:mm:ss. The current regex matches dates in the format YYYY-MM-DD. Please update the regex to match the expected format.

  • File: src/utils/validators/graphqlQueryValidators.ts
  • Lines: 1-5
Analysis chain

Ensure date format validation.

Ensure that fromDate and toDate are validated to match the expected format YYYYMMDD HH:mm:ss.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `fromDate` and `toDate` are validated to match the expected format.

# Test: Search for usage of `resourcePerDateReportValidator`. Expect: Matches in the query file.
rg --type js --type ts 'resourcePerDateReportValidator'

Length of output: 1056


Script:

#!/bin/bash
# Description: Verify that `resourcePerDateReportValidator` validates `fromDate` and `toDate` to match the expected format.

# Test: Extract the definition of `resourcePerDateReportValidator` to check the validation rules.
rg --type js --type ts 'resourcePerDateReportValidator' -A 10

Length of output: 9873


Script:

#!/bin/bash
# Description: Verify that `resourcePerDateRegex` matches the expected date format `YYYYMMDD HH:mm:ss`.

# Test: Extract the definition of `resourcePerDateRegex` to check the regex pattern.
rg --type js --type ts 'resourcePerDateRegex'

Length of output: 342


Script:

#!/bin/bash
# Description: Extract the full definition of `resourcePerDateRegex` to verify the regex pattern.

# Test: Extract the definition of `resourcePerDateRegex` from `src/utils/validators/graphqlQueryValidators.ts`.
rg --type js --type ts 'const resourcePerDateRegex' -A 5

Length of output: 566

src/services/recurringDonationService.ts Show resolved Hide resolved
src/services/recurringDonationService.ts Show resolved Hide resolved
src/services/recurringDonationService.ts Show resolved Hide resolved
src/services/recurringDonationService.ts Show resolved Hide resolved
@Meriem-BM Meriem-BM merged commit c217c1c into staging Jul 23, 2024
5 checks passed
@Meriem-BM Meriem-BM deleted the fix/track_recurring_donations branch July 23, 2024 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant