mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Using MetaPipe (*|) as in-filter separator
This commit is contained in:
@@ -147,7 +147,7 @@ const (
|
||||
CSV_SEP = ','
|
||||
FALLBACK_SEP = ';'
|
||||
INFIELD_SEP = ";"
|
||||
SUBFIELD_SEP = "|"
|
||||
MetaPipe = "*|"
|
||||
FIELDS_SEP = ","
|
||||
InInFieldSep = ":"
|
||||
STATIC_HDRVAL_SEP = "::"
|
||||
|
||||
@@ -36,7 +36,7 @@ func NewRSRField(fldStr string) (fld *RSRField, err error) {
|
||||
return nil, fmt.Errorf("Invalid FilterStartValue in string: %s", fldStr)
|
||||
}
|
||||
fltrVal := fldStr[fltrStart+1 : len(fldStr)-1]
|
||||
filters, err = ParseRSRFilters(fltrVal, SUBFIELD_SEP)
|
||||
filters, err = ParseRSRFilters(fltrVal, MetaPipe)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Invalid FilterValue in string: %s, err: %s", fltrVal, err.Error())
|
||||
}
|
||||
@@ -147,16 +147,12 @@ func (rsrf *RSRField) RegexpMatched() bool { // Investigate whether we had a reg
|
||||
}
|
||||
|
||||
func (rsrf *RSRField) FilterPasses(value string) bool {
|
||||
fmt.Printf("RSRField: %s, filterPasses value: <%q>\n", ToJSON(rsrf), value)
|
||||
if len(rsrf.filters) == 0 { // No filters
|
||||
return true
|
||||
}
|
||||
parsedVal := rsrf.ParseValue(value)
|
||||
fmt.Printf("parsedVal: %s\n", parsedVal)
|
||||
filterPasses := false
|
||||
fmt.Printf("having filters: %s, len(filters): %d\n", ToJSON(rsrf.filters), len(rsrf.filters))
|
||||
for _, fltr := range rsrf.filters {
|
||||
fmt.Printf("Checking filter: %s")
|
||||
if fltr.Pass(parsedVal) {
|
||||
filterPasses = true
|
||||
}
|
||||
@@ -194,7 +190,6 @@ type RSRFilter struct {
|
||||
}
|
||||
|
||||
func (rsrFltr *RSRFilter) Pass(val string) bool {
|
||||
fmt.Printf("Filter with rule: %s, parsing val: %q\n", rsrFltr.filterRule, val)
|
||||
if rsrFltr.filterRule == "" {
|
||||
return !rsrFltr.negative
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user