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

IBX-6827: Aggregation API improvements #287

Merged
merged 8 commits into from
Dec 12, 2023
Merged

IBX-6827: Aggregation API improvements #287

merged 8 commits into from
Dec 12, 2023

Conversation

adamwojs
Copy link
Member

@adamwojs adamwojs commented Oct 22, 2023

Question Answer
JIRA issue IBX-6827
Required by ibexa/solr#56, ibexa/elasticsearch#31
Type feature
Target Ibexa version v4.6
BC breaks no

This PR introduces several small Aggregation API improvements (DX).

Range::INF

Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range::INF const allows developers to be more verbose when defining open ranges:

// Before:
new Range(null, 100)

// After:
new Range(Range::INF, 100)

Range labels

Added label property with accessors to \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Range class.

new Range(Range::INF, new DateTime("01-01-2023"), "Published before 2023")

Labels can used latter on to render aggregation results.

Simplified access to Term & Range Aggregations Result keys

It's very common to use term aggregations to get top N terms e.g 10 most popular categories.

$aggregation = new TaxonomyEntryIdAggregation('most_popular_categories');
$aggregation->setLimit(10);

In this use case we are not interested into how many object belongs to specific bucket. \Ibexa\Contracts\Core\Repository\Values\Content\Search\AggregationResult\TermAggregationResult::getKeys method allows to retrieve terms without need to manually iterate over result entries.

Ranges generators

Step generators

$generator = new DateTimeStepRangesGenerator(new DateTime('2023-01-01'), new DateTime('2023-12-31'));
$generator->setStep(new DateInterval("P1M"));
$generator->setRightOpen(false);
$generator->setLeftOpen(true);

$aggregation = new DateRangeAggregation('enent_by_date', 'event', 'date', $generator->generate());

Related PRs:

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (main for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ibexa/engineering).

Copy link

sonarcloud bot commented Nov 4, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
5.6% 5.6% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@adamwojs adamwojs marked this pull request as ready for review December 7, 2023 07:30
@adamwojs adamwojs requested a review from a team December 7, 2023 07:33
@konradoboza konradoboza requested a review from a team December 11, 2023 07:25
@alongosz alongosz requested a review from a team December 11, 2023 13:10
@alongosz alongosz added the Feature New feature request label Dec 11, 2023
Copy link

sonarcloud bot commented Dec 11, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

No Coverage information No Coverage information
2.6% 2.6% Duplication

@alongosz alongosz requested a review from a team December 12, 2023 12:34
@adamwojs adamwojs merged commit 9111b08 into main Dec 12, 2023
23 checks passed
@adamwojs adamwojs deleted the ibx_6827 branch December 12, 2023 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants