-
Notifications
You must be signed in to change notification settings - Fork 71
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
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: +59 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
Manual test✅ - Manual test passes I have 22 disputes on my test site. I enforced the code to always do endpoint export for the purpose of testing.
|
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.
Code changes look fine and good to ship. One small linter comment about undefined var to be removed.
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 applying this filter consistently across the /disputes
, /disputes/summary
, /disputes/download
endpoints.
The disputes list view filtering works as expected for the:
Needs response
filter ✅Advanced
filter ✅- no filter ✅
CSV exporting is also working as intended ✅
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