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

All groups for output #314

Merged
merged 5 commits into from
Oct 31, 2020
Merged

All groups for output #314

merged 5 commits into from
Oct 31, 2020

Conversation

jnthn
Copy link
Collaborator

@jnthn jnthn commented Oct 30, 2020

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 theenums 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).

jnthn added 2 commits October 30, 2020 12:56
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.
@jnthn
Copy link
Collaborator Author

jnthn commented Oct 30, 2020

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).

@zaucker
Copy link
Contributor

zaucker commented Oct 30, 2020

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 {
Copy link
Collaborator Author

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. :-)

Copy link
Collaborator Author

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!) {
Copy link
Contributor

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 {
Copy link
Contributor

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,

@zaucker zaucker merged commit ebd1172 into master Oct 31, 2020
@zaucker zaucker deleted the all-groups-for-output branch October 31, 2020 20:03
@zaucker zaucker mentioned this pull request Nov 5, 2020
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