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

fix(payments): add time range in list payment attempts query #5959

Merged
merged 9 commits into from
Sep 19, 2024

Conversation

apoorvdixit88
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 commented Sep 19, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

  • Add time range to filter total count for payment attempt list.
  • Move TimeRange type to common utils so that it can be used in diesel models and across all the other api models

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

Closes #5958

How did you test it?

The expected behaviour is same, the query that is getting printed, is now also considering time range.

SELECT COUNT(*) FROM "payment_attempt" WHERE ((("payment_attempt"."merchant_id" = $1) 
AND ("payment_attempt"."attempt_id" = ANY($2))) AND ("payment_attempt"."created_at" >= $3)) 
-- binds: [MerchantId("merchant_1726040792"), [], 2024-08-19 18:30:00.0]

Request

curl --location 'http://localhost:8080/payments/list' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data '{
    "start_time": "2024-08-19T18:30:00Z"
}'

Response:

{
    "count": 0,
    "total_count": 0,
    "data": []
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@apoorvdixit88 apoorvdixit88 added C-bug Category: Bug S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-payments Area: payments A-Analytics labels Sep 19, 2024
@apoorvdixit88 apoorvdixit88 self-assigned this Sep 19, 2024
@apoorvdixit88 apoorvdixit88 requested review from a team as code owners September 19, 2024 11:00
Copy link

semanticdiff-com bot commented Sep 19, 2024

Review changes with SemanticDiff.

Analyzed 40 of 40 files.

Overall, the semantic diff is 10% smaller than the GitHub diff.

File Information
Filename Status
✔️ crates/storage_impl/src/payouts/payouts.rs Analyzed
✔️ crates/storage_impl/src/payments/payment_attempt.rs Analyzed
✔️ crates/storage_impl/src/payments/payment_intent.rs Analyzed
✔️ crates/storage_impl/src/mock_db/payment_attempt.rs Analyzed
✔️ crates/storage_impl/src/mock_db/payment_intent.rs Analyzed
✔️ crates/storage_impl/src/mock_db/payouts.rs Analyzed
✔️ crates/router/src/types/storage/dispute.rs Analyzed
✔️ crates/router/src/types/storage/refund.rs Analyzed
✔️ crates/router/src/types/api/payments.rs 9.09% smaller
✔️ crates/router/src/routes/disputes.rs Analyzed
✔️ crates/router/src/routes/payments.rs Analyzed
✔️ crates/router/src/routes/payouts.rs Analyzed
✔️ crates/router/src/routes/refunds.rs Analyzed
✔️ crates/router/src/db/dispute.rs Analyzed
✔️ crates/router/src/db/kafka_store.rs Analyzed
✔️ crates/router/src/db/refund.rs Analyzed
✔️ crates/router/src/core/disputes.rs Analyzed
✔️ crates/router/src/core/payments.rs Analyzed
✔️ crates/router/src/core/payouts.rs Analyzed
✔️ crates/router/src/core/refunds.rs Analyzed
✔️ crates/openapi/src/openapi.rs 25.55% smaller
✔️ crates/openapi/src/openapi_v2.rs 25.55% smaller
✔️ crates/hyperswitch_domain_models/src/payouts.rs Analyzed
✔️ crates/hyperswitch_domain_models/src/refunds.rs Analyzed
✔️ crates/hyperswitch_domain_models/src/payouts/payouts.rs Analyzed
✔️ crates/hyperswitch_domain_models/src/payments/payment_attempt.rs Analyzed
✔️ crates/hyperswitch_domain_models/src/payments/payment_intent.rs Analyzed
✔️ crates/diesel_models/src/query/payment_attempt.rs Analyzed
✔️ crates/common_utils/src/events.rs Analyzed
✔️ crates/common_utils/src/types.rs Analyzed
✔️ crates/api_models/src/analytics.rs Analyzed
✔️ crates/api_models/src/events.rs Analyzed
✔️ crates/api_models/src/payments.rs Analyzed
✔️ crates/api_models/src/payouts.rs Analyzed
✔️ crates/api_models/src/refunds.rs Analyzed
✔️ crates/api_models/src/analytics/search.rs Analyzed
✔️ crates/analytics/src/opensearch.rs 51.24% smaller
✔️ crates/analytics/src/disputes/metrics.rs 76.78% smaller
✔️ api-reference-v2/openapi_spec.json Analyzed
✔️ api-reference/openapi_spec.json Analyzed

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Sep 19, 2024
@apoorvdixit88 apoorvdixit88 changed the title fix(payments): add time range in attempt query list fix(payments): add time range in payment attempt query list Sep 19, 2024
@apoorvdixit88 apoorvdixit88 changed the title fix(payments): add time range in payment attempt query list fix(payments): add time range in list payment attempts query Sep 19, 2024
tsdk02
tsdk02 previously approved these changes Sep 19, 2024
dracarys18
dracarys18 previously approved these changes Sep 19, 2024
Chethan-rao
Chethan-rao previously approved these changes Sep 19, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Sep 19, 2024
@tsdk02 tsdk02 self-requested a review September 19, 2024 14:24
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 19, 2024
Merged via the queue into main with commit 156a161 Sep 19, 2024
14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the add-time-range-to-count-query branch September 19, 2024 18:20
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analytics A-payments Area: payments C-bug Category: Bug M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: add time_range constraint to retrieve payment attempt list
6 participants