-
Notifications
You must be signed in to change notification settings - Fork 69
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
Use the filter param in server-side disputes CSV export #9988
base: develop
Are you sure you want to change the base?
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: +83 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
client/data/disputes/resolvers.js
Outdated
const queryWithSearch = { | ||
...query, | ||
search: | ||
query.filter === 'awaiting_response' | ||
? disputeAwaitingResponseStatuses | ||
: query.search, | ||
}; | ||
|
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.
💭 it might be better for consistency to apply this in a single place for all /disputes/
,/disputes/download
,/disputes/summary
API requests – I think formatQueryFilters
in this file would be suitable since it is also where we are modifying the query in other ways.
const formatQueryFilters = ( query ) => ( {
user_email: query.userEmail,
match: query.match,
store_currency_is: query.storeCurrencyIs,
date_before: formatDateValue( query.dateBefore, true ),
date_after: formatDateValue( query.dateAfter ),
date_between: query.dateBetween && [
formatDateValue( query.dateBetween[ 0 ] ),
formatDateValue( query.dateBetween[ 1 ], true ),
],
- search: query.search,
+ // If `awaiting_response` filter is present, use the `search` query to select only those disputes awaiting a response.
+ search:
+ query.filter === 'awaiting_response'
+ ? disputeAwaitingResponseStatuses
+ : query.search,
status_is: query.statusIs,
status_is_not: query.statusIsNot,
locale: query.locale,
} );
This would then mean we can apply the same filtering to all requests, reducing the chance of inconsistency bugs like the one we're solving in this PR.
We implemented (or really, I did, if looking at git blame
) the following awaiting_response
filtering in the useDisputes
hook, which can be removed if we apply this logic across to all "dispute list" requests. We'd have to do some extra testing to make sure we don't break those endpoints, but it would be worth it IMO.
woocommerce-payments/client/data/disputes/hooks.ts
Lines 101 to 104 in a89f434
const search = | |
filter === 'awaiting_response' | |
? disputeAwaitingResponseStatuses | |
: undefined; |
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.
Not to say your solution doesn't work, by the way! But it will mean we are applying this logic in different places for different endpoints (/disputes/
, /disputes/download
, /disputes/summary
).
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 for the review @Jinksi, I've consolidated the code into formatQueryFilters
Fixes #9987
Filtering for
awaiting_response
was implemented separately foruseDisputes
anduseDisputesSummary
and missing forgetDisputesCSV
, causing the bug where the CSV was not filtered.Changes proposed in this Pull Request
awaiting_response
informatQueryFilters
hooks.ts
filter
param togetDisputesCSV
Testing instructions
Needs Response
and advanced filters.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge