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

Function priceMatch

internal/tui/views/pricing.go:611–645  ·  view source on GitHub ↗
(item PricingDisplayItem, priceTags []string)

Source from the content-addressed store, hash-verified

609}
610
611func priceMatch(item PricingDisplayItem, priceTags []string) bool {
612 if len(priceTags) == 0 {
613 return true
614 }
615 var mpVal float64
616 if item.MinPrice != "" && item.MinPrice != "-" {
617 s := strings.TrimSpace(item.MinPrice)
618 if strings.EqualFold(s, "na") || strings.EqualFold(s, "n/a") {
619 mpVal = 0
620 } else {
621 v, _ := strconv.ParseFloat(s, 64)
622 mpVal = v
623 }
624 }
625 for _, pt := range priceTags {
626 if strings.HasPrefix(pt, ">=") {
627 if v, err := strconv.ParseFloat(pt[2:], 64); err == nil && !(mpVal >= v) {
628 return false
629 }
630 } else if strings.HasPrefix(pt, "<=") {
631 if v, err := strconv.ParseFloat(pt[2:], 64); err == nil && !(mpVal <= v) {
632 return false
633 }
634 } else if strings.HasPrefix(pt, ">") {
635 if v, err := strconv.ParseFloat(pt[1:], 64); err == nil && !(mpVal > v) {
636 return false
637 }
638 } else if strings.HasPrefix(pt, "<") {
639 if v, err := strconv.ParseFloat(pt[1:], 64); err == nil && !(mpVal < v) {
640 return false
641 }
642 }
643 }
644 return true
645}
646
647// ConvertResponse transforms an API response into display items.
648func ConvertResponse(resp *api.PricingAPIResponse) []PricingDisplayItem {

Callers 1

FilterItemsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected