juspay/hyperswitch

[REFACTOR] Update db_metrics Operation to Use Count Instead of Filter in get_intent_status_with_count

Open

#5,988 opened on Sep 22, 2024

View on GitHub
 (4 comments) (0 reactions) (1 assignee)Rust (4,676 forks)batch import
A-AnalyticsA-paymentsC-refactorS-awaiting-triagehacktoberfest

Repository metrics

Stars
 (42,690 stars)
PR merge metrics
 (Avg merge 6d 22h) (213 merged PRs in 30d)

Description

Feature Description

In the get_intent_status_with_count function, we're retrieving the count of payment intents grouped by IntentStatus. The current code is tracking this operation as a Filter operation in db_metrics::DatabaseOperation. However, since we're counting records, this should be tracked as a Count operation instead.

Possible Implementation

The task is to update the db_metrics::DatabaseOperation in this function from Filter to Count.

Test

Use the following curl to test the api

curl --location 'http://localhost:8080/payments/aggregate?start_time=2022-08-20T11%3A33%3A39.000Z' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer JWT'

To get the JWT token, we can do signup and then skip 2FA with the following

curl --location 'http://localhost:8080/user/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
    "email": "JohnTest@test.com",
    "password": "Test@321"
}'

This will give an intermediate token in response, we need to use this token to skip 2FA

curl --location 'http://localhost:8080/user/2fa/terminate?skip_two_factor_auth=true' \
--header 'Authorization: Bearer Intermediatetoken'

After that hit the aggregate api to get the response, if no payments are there then all status count should be 0

Have you spent some time checking if this feature request has been raised before?

  • I checked and didn't find a similar issue

Submission Process:

  • Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
  • Once assigned, submit a pull request (PR).
  • Maintainers will review and provide feedback, if any.
  • Maintainers can unassign issues due to inactivity, read more here.

Refer here for Terms and conditions for the contest.

Contributor guide