mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
CDR filter on OriginIDs
This commit is contained in:
committed by
Dan Christian Bogos
parent
537b0241df
commit
6e384d0dea
@@ -526,6 +526,13 @@ func testGetCDRs(cfg *config.CGRConfig) error {
|
||||
} else if len(CDRs) != 5 {
|
||||
return fmt.Errorf("testGetCDRs #23, unexpected number of CDRs returned: %+v", CDRs)
|
||||
}
|
||||
// Filter on OriginID
|
||||
if CDRs, _, err := cdrStorage.GetCDRs(&utils.CDRsFilter{OriginIDs: []string{
|
||||
"testevent1", "testevent3"}}, false); err != nil {
|
||||
return fmt.Errorf("testGetCDRs #22 err: %v", err)
|
||||
} else if len(CDRs) != 5 {
|
||||
return fmt.Errorf("testGetCDRs #23, unexpected number of CDRs returned: %+v", CDRs)
|
||||
}
|
||||
// Filter on TOR
|
||||
if CDRs, _, err := cdrStorage.GetCDRs(&utils.CDRsFilter{ToRs: []string{utils.SMS}}, false); err != nil {
|
||||
return fmt.Errorf("testGetCDRs #23 err: %v", err)
|
||||
|
||||
@@ -1004,6 +1004,7 @@ func (ms *MongoStorage) GetCDRs(qryFltr *utils.CDRsFilter, remove bool) ([]*CDR,
|
||||
filters := bson.M{
|
||||
CGRIDLow: bson.M{"$in": qryFltr.CGRIDs, "$nin": qryFltr.NotCGRIDs},
|
||||
RunIDLow: bson.M{"$in": qryFltr.RunIDs, "$nin": qryFltr.NotRunIDs},
|
||||
OriginIDLow: bson.M{"$in": qryFltr.OriginIDs, "$nin": qryFltr.NotOriginIDs},
|
||||
OrderIDLow: bson.M{"$gte": qryFltr.OrderIDStart, "$lt": qryFltr.OrderIDEnd},
|
||||
ToRLow: bson.M{"$in": qryFltr.ToRs, "$nin": qryFltr.NotToRs},
|
||||
CDRHostLow: bson.M{"$in": qryFltr.OriginHosts, "$nin": qryFltr.NotOriginHosts},
|
||||
|
||||
@@ -868,6 +868,12 @@ func (self *SQLStorage) GetCDRs(qryFltr *utils.CDRsFilter, remove bool) ([]*CDR,
|
||||
if len(qryFltr.NotRunIDs) != 0 {
|
||||
q = q.Where("run_id not in (?)", qryFltr.NotRunIDs)
|
||||
}
|
||||
if len(qryFltr.OriginIDs) != 0 {
|
||||
q = q.Where("origin_id in (?)", qryFltr.OriginIDs)
|
||||
}
|
||||
if len(qryFltr.NotOriginIDs) != 0 {
|
||||
q = q.Where("origin_id not in (?)", qryFltr.NotOriginIDs)
|
||||
}
|
||||
if len(qryFltr.ToRs) != 0 {
|
||||
q = q.Where("tor in (?)", qryFltr.ToRs)
|
||||
}
|
||||
|
||||
@@ -806,8 +806,9 @@ type ExportedFileCdrs struct {
|
||||
}
|
||||
|
||||
type AttrGetCdrs struct {
|
||||
CgrIds []string // If provided, it will filter based on the cgrids present in list
|
||||
MediationRunIds []string // If provided, it will filter on mediation runid
|
||||
CgrIds []string // If provided, it will filter based on the cgrids present in list
|
||||
MediationRunIds []string // If provided, it will filter on mediation runid
|
||||
|
||||
TORs []string // If provided, filter on TypeOfRecord
|
||||
CdrHosts []string // If provided, it will filter cdrhost
|
||||
CdrSources []string // If provided, it will filter cdrsource
|
||||
@@ -1004,6 +1005,8 @@ type CDRsFilter struct {
|
||||
NotCGRIDs []string // Filter specific CgrIds out
|
||||
RunIDs []string // If provided, it will filter on mediation runid
|
||||
NotRunIDs []string // Filter specific runIds out
|
||||
OriginIDs []string // If provided, it will filter on OriginIDs
|
||||
NotOriginIDs []string // Filter specific OriginIDs out
|
||||
OriginHosts []string // If provided, it will filter cdrhost
|
||||
NotOriginHosts []string // Filter out specific cdr hosts
|
||||
Sources []string // If provided, it will filter cdrsource
|
||||
@@ -1052,6 +1055,8 @@ type RPCCDRsFilter struct {
|
||||
NotCGRIDs []string // Filter specific CgrIds out
|
||||
RunIDs []string // If provided, it will filter on mediation runid
|
||||
NotRunIDs []string // Filter specific runIds out
|
||||
OriginIDs []string // If provided, it will filter on OriginIDs
|
||||
NotOriginIDs []string // Filter specific OriginIDs out
|
||||
OriginHosts []string // If provided, it will filter cdrhost
|
||||
NotOriginHosts []string // Filter out specific cdr hosts
|
||||
Sources []string // If provided, it will filter cdrsource
|
||||
@@ -1097,6 +1102,8 @@ func (self *RPCCDRsFilter) AsCDRsFilter(timezone string) (*CDRsFilter, error) {
|
||||
NotCGRIDs: self.NotCGRIDs,
|
||||
RunIDs: self.RunIDs,
|
||||
NotRunIDs: self.NotRunIDs,
|
||||
OriginIDs: self.OriginIDs,
|
||||
NotOriginIDs: self.NotOriginIDs,
|
||||
ToRs: self.ToRs,
|
||||
NotToRs: self.NotToRs,
|
||||
OriginHosts: self.OriginHosts,
|
||||
|
||||
Reference in New Issue
Block a user