openshift/origin-server — pull request #5442 by Miciah (2014-05-23 00:26:39+00:00)
Title: Console: Improve grouping of application types

Improve the algorithm `Console::ModelHelper#in_groups_by_tag` to consider application types for grouping under a tag even for a type that has previously matched a tag that had only one match.

`in_groups_by_tag` takes a list of application types and tags and returns two arrays: One with the application types grouped tags that they match and one with application types that have no tags that more than one application type matches.

The algorithm iterates over the array of tags that is passed into it. For each tag in this array, the algorithm pulls out each type that matches the tag. After iterating over the array of types while matching them against the iterator tag, the algorithm either creates a new grouping of all types that matched the tag if there were more than one, or else the algorithm puts any matching type in the "other" group.

The problem is that jbosseap-6 has the "xpaas" tag, which comes before the "java" tag in the array of tags provided to `in_groups_by_tag`. Thus the jbosseap-6 cartridge is found to match the "xpaas" tag before the "java" tag is considered. However, jbosseap-6 is the only cartridge with the "xpaas" tag, so it is placed on the "other" group before the "java" tag is considered. Thus by the time the "java" tag is considered, jbosseap-6 has already been pulled into the "others" group and is not in the array considered for consideration when matching types against the "java" tag.

This commit changes the algorithm instead to leave types in the array of types for consideration for matching against tags until that type is found to be one of multiple types that match some tag.

This commit fixes bug 1100508.