-
Notifications
You must be signed in to change notification settings - Fork 2
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
All groups for output #314
Conversation
Parse the value language string up front, when we create the input, so that we don't have to do it every time we call `as-hash`, and also so we don't have `.enums` handing back an unparsed string in its value.
Keep track of the filter sets that contribute to a filter group in the outputs. With the possible options in the enum attached to the filter sets, this means we can produce all of the filter keys that could ever occur. Use this to offer a means to get all of the filter group's values including zero entries for those that have no instances using those enum options. The options are sorted according to the enum within a given module, however the order of modules is undetermined.
This also probably helps with #301 in so far as the code in that area is cleaned up by this PR (although it still needs attention). |
Will extend the other OutputFormatters in separate PR. |
die "Can only get all values when provenance of the filter group was provided"; | ||
} | ||
my @results; | ||
for $!provenance.keys.sort.reverse -> $filter-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.
Unfortunately, this sort
is not going to do anything useful. It is a sort
on instances of Agrammon::Model::FilterSet
, and will sort on memory location or some such. :-)
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 did 437fbcc but I don't know if it's what you actually want. :-)
|
||
submethod BUILD(:@instances!) { | ||
submethod BUILD(:$!provenance = ∅, :@instances!) { |
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.
Cute, finally a useful application of the ∅ ... after having being introduced to it in 5th grade almost 50 years ago :-)
die "Can only get all values when provenance of the filter group was provided"; | ||
} | ||
my @results; | ||
for $!provenance.keys.sort(*.module.taxonomy).reverse -> $filter-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.
This sort does almost what we need. Will make a separate PR for it,
This hopefully provides a solution to #299. If you call
.results-by-filter-group(:all)
(note the new ':allnamed argument), then it will include all possible filter keys that could exist (based on the
enums in the definitions) rather than just those that have been used in an instance. A
0` value is given to those that have no instances.This is achieved by dynamic means: filter group collections are constructed with the filter set(s) from the model of all modules that contribute values to the group. This is mostly a case of passing it along, with the exception of pairwise operations which need to perform a union of the module filter sets (thus how a
P+
involving two different modules will end up with the filter sets of both being accounted for).Hopefully this provides the desired semantics, and also will make it an easy change in the output productions too (I did not update those; @zaucker it's probably best to check out this branch and have a go at updating the output logic and seeing if it does the right thing).