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

Add support for custom range key and refactor addRange in a trait #2227

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

SosthenG
Copy link
Contributor

IpRange and GeoDistance aggregations were missing the ability to specify a custom key for a range.
As it was already done for the Range aggregation, I moved that to a trait that is now used everywhere we need addRange.
For the IpRange aggregation, I also added the key option to the addMaskRange method.

The only drawback with this refactoring is that the arguments of the trait have to allow string|int|float|null to be usable everywhere and we loose some phpdoc details on the arguments. In my opinion, people using this should already know what format is expected and can always check the doc so I personally prefer to have the code deduplicated, but if you disagree I can change it back to add the key everywhere without using a common trait.

@ruflin
Copy link
Owner

ruflin commented Oct 11, 2024

Hi @SosthenG Sorry for the late reply. I'm currently on holidays but try to take a look at this rather soonish.

Copy link
Owner

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Change LGTM. I like that the new trait removes quite a bit of duplicated code and makes sure it stays in sync.

*
* @return $this
*/
public function addRange(?string $fromValue = null, ?string $toValue = null): self
public function addMaskRange(string $mask, ?string $key = null): self
Copy link
Owner

Choose a reason for hiding this comment

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

This is an additional change not directly tied to the trait is my understanding?

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 I did that as well because my original goal was to add support for the key option and the mask range was missing it too.

@ruflin ruflin merged commit 223a25f into ruflin:8.x Oct 21, 2024
18 checks passed
@ruflin
Copy link
Owner

ruflin commented Oct 21, 2024

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants