-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[API][Order] Filtering on the Orders list #15477
Conversation
Bunnyshell Preview Environment deletedAvailable commands:
|
public function __construct(private ContextAwareFilterInterface $dateFilter, private array $properties) | ||
{ | ||
} | ||
|
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.
Please remove second empty line
final class InclusiveDateRangeFilter implements ContextAwareFilterInterface | ||
{ | ||
/** | ||
* @param ContextAwareFilterInterface $dateFilter |
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.
This @param
is unnecessary, docblocs should only be added to cover arguable cases for static analysis.
} | ||
|
||
/** | ||
* @param QueryBuilder $queryBuilder |
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.
I guess only
* @param class-string $resourceClass
* @param array<string, mixed> $context
are needed, And
--- * @param string $resourceClass
+++ * @param class-string $resourceClass
|
||
private function isExclusive(mixed $value): bool | ||
{ | ||
if(!$value || !is_string($value)) { |
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.
if(!$value || !is_string($value)) { | |
if (!$value || !is_string($value)) { |
@@ -24,6 +24,13 @@ | |||
<attribute name="path">/admin/orders</attribute> | |||
<attribute name="filters"> | |||
<attribute>sylius.api.order_number_filter</attribute> | |||
<attribute>sylius.api.order_checkout_completed_at_filter</attribute> |
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.
Please sort them logically or alphabetically.
For example.
<attribute>sylius.api.order_number_filter</attribute>
<attribute>sylius.api.order_checkout_completed_at_filter</attribute>
<attribute>sylius.api.order_currency_code_filter</attribute>
<attribute>sylius.api.order_total_filter</attribute>
<attribute>sylius.api.order_channel_filter</attribute>
<attribute>sylius.api.order_shipping_method_filter</attribute>
<attribute>sylius.api.order_products_filter</attribute>
<attribute>sylius.api.order_variants_filter</attribute>
/** | ||
* @When I specify filter total being greater than :total | ||
*/ | ||
public function iSpecifyFilterTotalBeingGreaterThan($total) |
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.
float/string $total?
public function iSpecifyFilterTotalBeingGreaterThan($total) | |
public function iSpecifyFilterTotalBeingGreaterThan($total): void |
*/ | ||
public function iSpecifyFilterTotalBeingGreaterThan($total) | ||
{ | ||
$this->client->addFilter('total[gt]', $total* 100); |
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.
$this->client->addFilter('total[gt]', $total* 100); | |
$this->client->addFilter('total[gt]', $total * 100); |
*/ | ||
public function iSpecifyFilterTotalBeingLessThan($total) | ||
{ | ||
$this->client->addFilter('total[lt]', $total* 100); |
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.
$this->client->addFilter('total[lt]', $total* 100); | |
$this->client->addFilter('total[lt]', $total * 100); |
/** | ||
* @When I specify filter total being less than :total | ||
*/ | ||
public function iSpecifyFilterTotalBeingLessThan($total) |
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.
public function iSpecifyFilterTotalBeingLessThan($total) | |
public function iSpecifyFilterTotalBeingLessThan(float/string? $total): void |
|
||
/** | ||
* @When /^I filter by (variants "([^"]+)" and "([^"]+)")$/ | ||
* @param ProductVariantInterface $variants |
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.
Please remove this line unless necessary by phpstan
@LGouttefange Hi, great filtering coverage. 👍 I've commented on a few minor points, please take a look. |
0427857
to
828cc9d
Compare
828cc9d
to
48e9449
Compare
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.
Thank you @diimpp for the thorough review. I've updated & commented some points
I also fixed the coding standards issues, but - bit of a newbie question - please let me know if I should resolve them myself, or let you handle those 🙏 thanks !
private function isExclusive(mixed $value): bool | ||
{ | ||
if(!$value || !is_string($value)) { | ||
return false; |
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.
I've pushed a new version of the Filter class, taking inspiration of the mentioned filter.
In the case of a Filter decorator, I didn't want to overstep or reproduce the base DateFilter validation & error handling, hence why I am not actively validating the item and just returning it as such.
Closing as already done in #15566. Thanks! |
Included in this PR:
As this is my first PR here, I am open to any feedback 🙏