-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/optional bounds for filters #1546
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
Conversation
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 have to admit it's a bit of an end-of-the-day review, but the test coverage gives me the confidence to approve it anyway.
I especially like the models/aggregation.ts
file!
this.searchService.aggregateSearch(queryModel.corpus, queryModel, aggregator).then(result => | ||
this.options = _.sortBy( | ||
result.map(x => ({ label: x.key, value: x.key, doc_count: x.doc_count })), | ||
o => o.label | ||
) | ||
).catch(() => this.options = []); |
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 would prefer meaningful variable names over x
and o
, or type annotations. The code is already quite difficult to read.
I know this is not in the scope of the PR, but just stood out to me now that it's presented to me :)
[range]="true" [min]="min" [max]="max" | ||
(onChange)="sliderValue$.next($event.values)"></p-slider> | ||
</div> | ||
<ng-container *ngIf="min !== undefined && max !== 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.
I presume the *ngIf
is to delay loading the component until after the min
and max
are set?
In that case we need to be sure that these are always set.
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.
Yes, you can't really make a slider otherwise. The same component should be requesting a min/max value.
@@ -0,0 +1,163 @@ | |||
import { CorpusField } from './corpus'; |
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.
By god this is great.
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 the import. The file.
This makes the specification of
upper
andlower
bound for the range filter and date filter optional (close #1535). If no upper or lower bound has been defined, the frontend will request the min/max values when rendering the filter component.Summary of changes to the code:
searchService
.aggregateSearch()
is now as general as the name implies, and allows aggregations other than theterms
type.dateHistogramSearch()
is removed.Aggregator
class with subclasses for specific aggregation types. This class handles the translation to an elasticsearch query, and translation from an elasticsearch result.terms
anddate_histogram
aggregations as the same type, but they are not compatible. Changed the definitions so these are different return types.RangeFilter
andDateFilter
now acceptundefined
min/max values (i.e. no bound). If the corpus did not specify an upper/lower bound, these will be the initial values.