mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
better match filter
This commit is contained in:
@@ -84,9 +84,9 @@ func (b *Balance) MatchFilter(o *Balance) bool {
|
||||
}
|
||||
return (o.ExpirationDate.IsZero() || b.ExpirationDate.Equal(o.ExpirationDate)) &&
|
||||
(o.Weight == 0 || b.Weight == o.Weight) &&
|
||||
(len(o.DestinationIds) == 0 || b.DestinationIds.Equal(o.DestinationIds)) &&
|
||||
(len(o.Directions) == 0 || b.Directions.Equal(o.Directions)) &&
|
||||
(len(o.Categories) == 0 || b.Categories.Equal(o.Categories)) &&
|
||||
(len(o.DestinationIds) == 0 || b.DestinationIds.Includes(o.DestinationIds)) &&
|
||||
(len(o.Directions) == 0 || b.Directions.Includes(o.Directions)) &&
|
||||
(len(o.Categories) == 0 || b.Categories.Includes(o.Categories)) &&
|
||||
(o.RatingSubject == "" || b.RatingSubject == o.RatingSubject) &&
|
||||
(o.SharedGroup == "" || b.SharedGroup == o.SharedGroup)
|
||||
}
|
||||
|
||||
12
utils/map.go
12
utils/map.go
@@ -97,6 +97,18 @@ func (sm StringMap) Equal(om StringMap) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (sm StringMap) Includes(om StringMap) bool {
|
||||
if len(sm) < len(om) {
|
||||
return false
|
||||
}
|
||||
for key := range om {
|
||||
if !sm[key] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (sm StringMap) Clone() StringMap {
|
||||
result := make(StringMap, len(sm))
|
||||
for k := range sm {
|
||||
|
||||
Reference in New Issue
Block a user