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(disputes): add filters for disputes list #5637

Merged
merged 25 commits into from
Sep 22, 2024

Conversation

apoorvdixit88
Copy link
Contributor

@apoorvdixit88 apoorvdixit88 commented Aug 15, 2024

Type of Change

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

Description

Add filters for disputes list

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 #5626

How did you test it?

The following endpoints will give profile or merchant level filters:
The start_time and end_time are in primitive data time format:
start_time=2024-07-03T18:00:00.000Z
end_time=2024-10-03T18:00:00.000Z

curl --location --request GET 'http://localhost:8080/disputes/filter' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data 
curl --location --request GET 'http://localhost:8080/disputes/profile/filter' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data 

Response: Set of dropdown filters:

{
    "connector": { List of configured connectors},
    "currency": [
        "AED",
        "ALL",
        "AMD",
 ... and other list of available currencies
    ],
    "dispute_status": [
        "dispute_opened",
        "dispute_expired",
        "dispute_accepted",
        "dispute_cancelled",
        "dispute_challenged",
        "dispute_won",
        "dispute_lost"
    ],
    "dispute_stage": [
        "pre_dispute",
        "dispute",
        "pre_arbitration"
    ]
}

The list api will accept set of filters in query param and gives desired response

curl --location 'http://localhost:8080/disputes/list?connector=c1,c2,c3&currency=cur1,cur2,cur3&dispute_stage=d1,d2&dispute_status=ds1,ds2' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data ''
curl --location 'http://localhost:8080/disputes/list?start_time=2024-07-03T18:00:00.000Z&end_time=2024-10-03T18:00:00.000Z' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer JWT' \
--data ''

Response will be list after applying the filters passed in query param.

[
    {
        "dispute_id": "dp_c5dsfPtddlzuGN6kEusg",
        "payment_id": "test_F2wxddVYyES3ZmxdYE07",
        "attempt_id": "test_F2wxddVYyES3ZmxdYE07_1",
        "amount": "1040",
        "currency": "GBP",
        "dispute_stage": "dispute",
        "dispute_status": "dispute_expired",
        "connector": "checkout",
        "connector_status": "DisputeExpired",
        "connector_dispute_id": "dsp_c0db6a8d577h763b1c00",
        "connector_reason": "",
        "connector_reason_code": "10.4",
        "challenge_required_by": "2024-07-03T18:00:00.000Z",
        "connector_created_at": "2024-06-13T14:39:16.710Z",
        "connector_updated_at": "2024-07-03T18:00:36.610Z",
        "created_at": "2024-06-13T14:39:17.037Z",
        "profile_id": "pro_cz810B3XlrAPQu69pCi6",
        "merchant_connector_id": "mca_6rzLRT6znmFkdTpSLu0x"
    }
    ]

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 requested review from a team as code owners August 15, 2024 17:30
@apoorvdixit88 apoorvdixit88 self-assigned this Aug 15, 2024
@apoorvdixit88 apoorvdixit88 marked this pull request as draft August 15, 2024 17:31
@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Sep 13, 2024
@apoorvdixit88 apoorvdixit88 force-pushed the add-filters-to-dispute-list branch from 55b83a2 to d10f28a Compare September 13, 2024 13:29
@hyperswitch-bot hyperswitch-bot bot removed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Sep 13, 2024
@apoorvdixit88 apoorvdixit88 marked this pull request as ready for review September 16, 2024 07:36
@apoorvdixit88 apoorvdixit88 added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed A-disputes Area: Dispute flows labels Sep 16, 2024
@apoorvdixit88 apoorvdixit88 requested review from hrithikesh026 and removed request for hrithikesh026 September 17, 2024 12:36
pub limit: Option<i64>,
pub struct DisputeListGetConstraints {
/// The identifier for dispute
pub dispute_id: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need dispute_id in DisputeListGetConstraints? We can use Dispute retrieve for point query right?

Copy link
Contributor Author

@apoorvdixit88 apoorvdixit88 Sep 20, 2024

Choose a reason for hiding this comment

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

Its good to have:

  • Users will be able to search for a specific dispute by its ID and see the result directly in the list and then it can be retrieved. If the dispute doesn't exist, the list page should display a message indicating that the dispute is not present.
  • Users will have the ability to search for disputes one by one, without needing to repeatedly navigate back to the retrieve page. They should be able to see disputes directly in list (if it exists), making the process more user-friendly and efficient.

time_range,
} = value;
let profile_id_from_request_body = profile_id;
let profile_id_list = match (profile_id_from_request_body, auth_profile_id_list) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain here with some code comments?

{
data
} else {
return Err(errors::ApiErrorResponse::InternalServerError.into());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please add an attach printable here?

Ok(locked_disputes
let limit_usize = dispute_constraints
.limit
.unwrap_or(u32::MAX)
Copy link
Contributor

Choose a reason for hiding this comment

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

It's not good idea to keep it to MAX if value is not present right?

Copy link
Contributor Author

@apoorvdixit88 apoorvdixit88 Sep 20, 2024

Choose a reason for hiding this comment

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

Its for MockDb we can change this. Will create good first issue for this.

pub dispute_stage: Option<DisputeStage>,
/// reason for the dispute
/// The comma separated list of status of the disputes
#[serde(default, deserialize_with = "parse_comma_separated")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the parse comma thing for backwards compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes and it will support for open source users too.
Also it is because we will be passing list in query params, Get api, so parsing logic is required. For passing lists like this there is also other syntax where actix will handle things, list[]=1&list[]=2. But for now as dashboard frontend is passing comma separated, for all the similar get apis where list is required, using the same for it.
Later we can change this if required.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Sep 22, 2024
Merged via the queue into main with commit 365f568 Sep 22, 2024
13 of 14 checks passed
@Gnanasundari24 Gnanasundari24 deleted the add-filters-to-dispute-list branch September 22, 2024 18:35
@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-disputes Area: Dispute flows C-feature Category: Feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(disputes): support filters in disputes list
5 participants