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 Extended Stats Bucket #1756

Merged
merged 13 commits into from
Mar 5, 2020
Merged

add Extended Stats Bucket #1756

merged 13 commits into from
Mar 5, 2020

Conversation

nicolassing
Copy link
Contributor

No description provided.

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.

Code LGTM. Could you add a changelog entry?

lib/Elastica/Aggregation/ExtendedStatsBucket.php Outdated Show resolved Hide resolved
lib/Elastica/Aggregation/ExtendedStatsBucket.php Outdated Show resolved Hide resolved
lib/Elastica/Aggregation/ExtendedStatsBucket.php Outdated Show resolved Hide resolved
lib/Elastica/Aggregation/ExtendedStatsBucket.php Outdated Show resolved Hide resolved
test/Elastica/Aggregation/ExtendedStatsBucketTest.php Outdated Show resolved Hide resolved
test/Elastica/Aggregation/ExtendedStatsBucketTest.php Outdated Show resolved Hide resolved
test/Elastica/Aggregation/ExtendedStatsBucketTest.php Outdated Show resolved Hide resolved
test/Elastica/Aggregation/ExtendedStatsBucketTest.php Outdated Show resolved Hide resolved

class ExtendedStatsBucketTest extends BaseAggregationTest
{
protected function _getIndexForTest(): Index
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use private as method visibility here

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is still protected :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is till protected, it should be private instead

@nicolassing
Copy link
Contributor Author

Hello @thePanz

I removed all useless comments and annotations ;)

Thx !

@ruflin
Copy link
Owner

ruflin commented Feb 17, 2020

Seems CI is not happy :-( @thePanz Feel free to merge as soon as you are happy and CI is green.

@nicolassing
Copy link
Contributor Author

Hey @thePanz Everything is ok for you ?
Thx !

*/
class ExtendedStatsBucket extends AbstractAggregation
{
public function __construct(string $name, ?string $bucketsPath = null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I just noticed it now: why is the bucketPath not required in the constructor, but later required when building the request( toArray())?

As it is required, I'd make it required (not empty) and remove the setBucketPath() method. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

@thePanz Perhaps the same argument as in the other PR might apply. No strong opinion which on is better but we should become consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i followed the model of the StatsBucket aggregation :/

But both of you are right. We can make the $bucketsPath argument mandatory and remove the setter in the 2 classes :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@nicolassing : I'd leave the setters (and do the "not empty" check there, throwing an exception)
and make the argument required in the constructor

I'll cleanup the other aggregations @ruflin , but in another PR. I'd like not to have devs creating invalid objects to start with :) but this is a topic for a discussion, not here tho :)

Copy link
Owner

Choose a reason for hiding this comment

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

SGTM, lets try it out.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But first: let's have the $bucketsPath argument as required :)

@ruflin
Copy link
Owner

ruflin commented Mar 3, 2020

@nicolassing Could you add a changelog entry? I think then this PR is good to go.

*/
public function toArray(): array
{
if (!$this->hasParam('buckets_path')) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not needed anymore

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 was correcting it ^^

{
parent::__construct($name);

if (null !== $bucketsPath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

the if condition is now always true

@nicolassing nicolassing requested a review from thePanz March 5, 2020 14:12
@thePanz thePanz merged commit 5ad7ea3 into ruflin:master Mar 5, 2020
@thePanz
Copy link
Collaborator

thePanz commented Mar 5, 2020

Merged! thanks @nicolassing for the PR, the changes and the patience 👍

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.

3 participants