mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-16 13:49:53 +05:00
Inline filter
This commit is contained in:
committed by
Dan Christian Bogos
parent
d0a0250e0f
commit
3e8b99d94e
@@ -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,
|
||||
|
||||
|
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user