MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / FilterItems

Method FilterItems

internal/tui/views/pricing.go:547–571  ·  view source on GitHub ↗

FilterItems filters items based on current builder tags.

()

Source from the content-addressed store, hash-verified

545
546// FilterItems filters items based on current builder tags.
547func (v *PricingView) FilterItems() {
548 rTags := lowered(v.CommandBuilder.RegionTags)
549 pTags := lowered(v.CommandBuilder.ProductTags)
550 aTags := lowered(v.CommandBuilder.AttributeTags)
551 priceTags := lowered(v.CommandBuilder.PriceTags)
552
553 if len(rTags) == 0 && len(pTags) == 0 && len(aTags) == 0 && len(priceTags) == 0 {
554 v.FilteredItems = append([]PricingDisplayItem{}, v.Items...)
555 v.Selected = 0
556 return
557 }
558
559 var filtered []PricingDisplayItem
560 for _, item := range v.Items {
561 regionOK := len(rTags) == 0 || containsAny(strings.ToLower(item.Region), rTags)
562 productOK := len(pTags) == 0 || containsAny(strings.ToLower(item.Product), pTags)
563 attrsOK := attrMatch(item, aTags)
564 priceOK := priceMatch(item, priceTags)
565 if regionOK && productOK && attrsOK && priceOK {
566 filtered = append(filtered, item)
567 }
568 }
569 v.FilteredItems = filtered
570 v.Selected = 0
571}
572
573func lowered(ss []string) []string {
574 out := make([]string, len(ss))

Callers 3

HandleKeyMethod · 0.95
handleKeyBuilderFieldMethod · 0.95
toggleSuggestionMethod · 0.95

Calls 4

loweredFunction · 0.85
containsAnyFunction · 0.85
attrMatchFunction · 0.85
priceMatchFunction · 0.85

Tested by

no test coverage detected