Inline filter

This commit is contained in:
TeoV
2018-01-13 17:50:58 +02:00
committed by Dan Christian Bogos
parent d0a0250e0f
commit 3e8b99d94e
2 changed files with 21 additions and 4 deletions

View File

@@ -1,3 +1,3 @@
#Tenant,ID,Contexts,FilterIDs,ActivationInterval,FieldName,Initial,Substitute,Append,Weight
cgrates.org,ATTR_1,*rating,FLTR_ACNT_1007,2014-01-14T00:00:00Z,Account,*any,1001,false,10
cgrates.org,ATTR_1,*rating,FLTR_ACNT_1007;*type:name:val,2014-01-14T00:00:00Z,Account,*any,1001,false,10
cgrates.org,ATTR_1,,,,Subject,*any,1001,true,
1 #Tenant ID Contexts FilterIDs ActivationInterval FieldName Initial Substitute Append Weight
2 cgrates.org ATTR_1 *rating FLTR_ACNT_1007 FLTR_ACNT_1007;*type:name:val 2014-01-14T00:00:00Z Account *any 1001 false 10
3 cgrates.org ATTR_1 Subject *any 1001 true

View File

@@ -70,14 +70,31 @@ func (fS *FilterS) connStatS() (err error) {
return
}
type InlineFilter struct {
Type string
FieldName string
FieldVal string
}
func NewInlineFilter(content string) (f *InlineFilter, err error) {
return
}
// PassFiltersForEvent will check all filters wihin filterIDs and require them passing for event
// there should be at least one filter passing, ie: if filters are not active event will fail to pass
func (fS *FilterS) PassFiltersForEvent(tenant string, ev map[string]interface{}, filterIDs []string) (pass bool, err error) {
var atLeastOneFilterPassing bool
for _, fltrID := range filterIDs {
f, err := fS.dm.GetFilter(tenant, fltrID, false, utils.NonTransactional)
if err != nil {
return false, err
var f *Filter
if strings.HasPrefix(fltrID, "*") {
fmt.Printf("fltr %+v", fltrID)
} else {
fmt.Printf("enter here with ID %s", fltrID)
f, err = fS.dm.GetFilter(tenant, fltrID, false, utils.NonTransactional)
if err != nil {
return false, err
}
}
if f.ActivationInterval != nil &&
!f.ActivationInterval.IsActiveAtTime(time.Now()) { // not active