mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
MediatorV1.RateCdrs with more filter options, renaming cdr arguments to reflect plurals properly
This commit is contained in:
@@ -121,8 +121,9 @@ func (self *ApierV1) ExportCdrsToFile(attr utils.AttrExpFileCdrs, reply *utils.E
|
||||
if attr.MaskLength != nil {
|
||||
maskLen = *attr.MaskLength
|
||||
}
|
||||
cdrs, err := self.CdrDb.GetStoredCdrs(attr.CgrIds, attr.MediationRunId, attr.TOR, attr.CdrHost, attr.CdrSource, attr.ReqType, attr.Direction,
|
||||
attr.Tenant, attr.Category, attr.Account, attr.Subject, attr.DestinationPrefix, attr.RatedAccount, attr.RatedSubject, attr.OrderIdStart, attr.OrderIdEnd, tStart, tEnd, attr.SkipErrors, attr.SkipRated, false)
|
||||
cdrs, err := self.CdrDb.GetStoredCdrs(attr.CgrIds, attr.MediationRunIds, attr.TORs, attr.CdrHosts, attr.CdrSources, attr.ReqTypes, attr.Directions,
|
||||
attr.Tenants, attr.Categories, attr.Accounts, attr.Subjects, attr.DestinationPrefixes, attr.RatedAccounts, attr.RatedSubjects, attr.OrderIdStart, attr.OrderIdEnd,
|
||||
tStart, tEnd, attr.SkipErrors, attr.SkipRated, false)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if len(cdrs) == 0 {
|
||||
|
||||
@@ -59,8 +59,8 @@ func (apier *ApierV1) GetCdrs(attrs utils.AttrGetCdrs, reply *[]*utils.CgrCdrOut
|
||||
return err
|
||||
}
|
||||
}
|
||||
if cdrs, err := apier.CdrDb.GetStoredCdrs(attrs.CgrIds, attrs.MediationRunId, attrs.TOR, attrs.CdrHost, attrs.CdrSource, attrs.ReqType, attrs.Direction,
|
||||
attrs.Tenant, attrs.Category, attrs.Account, attrs.Subject, attrs.DestinationPrefix, attrs.RatedAccount, attrs.RatedSubject,
|
||||
if cdrs, err := apier.CdrDb.GetStoredCdrs(attrs.CgrIds, attrs.MediationRunIds, attrs.TORs, attrs.CdrHosts, attrs.CdrSources, attrs.ReqTypes, attrs.Directions,
|
||||
attrs.Tenants, attrs.Categories, attrs.Accounts, attrs.Subjects, attrs.DestinationPrefixes, attrs.RatedAccounts, attrs.RatedSubjects,
|
||||
attrs.OrderIdStart, attrs.OrderIdEnd, tStart, tEnd, attrs.SkipErrors, attrs.SkipRated, false); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,11 @@ func (self *MediatorV1) RateCdrs(attrs utils.AttrRateCdrs, reply *string) error
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := self.Medi.RateCdrs(tStart, tEnd, attrs.RerateErrors, attrs.RerateRated); err != nil {
|
||||
//RateCdrs(cgrIds, runIds, tors, cdrHosts, cdrSources, reqTypes, directions, tenants, categories, accounts, subjects, destPrefixes []string,
|
||||
//orderIdStart, orderIdEnd int64, timeStart, timeEnd time.Time, rerateErrors, rerateRated bool)
|
||||
if err := self.Medi.RateCdrs(attrs.CgrIds, attrs.MediationRunIds, attrs.TORs, attrs.CdrHosts, attrs.CdrSources, attrs.ReqTypes, attrs.Directions,
|
||||
attrs.Tenants, attrs.Categories, attrs.Accounts, attrs.Subjects, attrs.DestinationPrefixes, attrs.RatedAccounts, attrs.RatedSubjects,
|
||||
attrs.OrderIdStart, attrs.OrderIdEnd, tStart, tEnd, attrs.RerateErrors, attrs.RerateRated); err != nil {
|
||||
return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error())
|
||||
}
|
||||
*reply = utils.OK
|
||||
|
||||
@@ -163,8 +163,10 @@ func (self *Mediator) RateCdr(storedCdr *utils.StoredCdr) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *Mediator) RateCdrs(timeStart, timeEnd time.Time, rerateErrors, rerateRated bool) error {
|
||||
cdrs, err := self.cdrDb.GetStoredCdrs(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0, 0, timeStart, timeEnd, !rerateErrors, !rerateRated, true)
|
||||
func (self *Mediator) RateCdrs(cgrIds, runIds, tors, cdrHosts, cdrSources, reqTypes, directions, tenants, categories, accounts, subjects, destPrefixes, ratedAccounts, ratedSubjects []string,
|
||||
orderIdStart, orderIdEnd int64, timeStart, timeEnd time.Time, rerateErrors, rerateRated bool) error {
|
||||
cdrs, err := self.cdrDb.GetStoredCdrs(cgrIds, runIds, tors, cdrHosts, cdrSources, reqTypes, directions, tenants, categories, accounts, subjects, destPrefixes, ratedAccounts, ratedSubjects,
|
||||
orderIdStart, orderIdEnd, timeStart, timeEnd, !rerateErrors, !rerateRated, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
"net/rpc/jsonrpc"
|
||||
"net/url"
|
||||
"os/exec"
|
||||
"path"
|
||||
@@ -127,7 +128,8 @@ func TestRpcConn(t *testing.T) {
|
||||
return
|
||||
}
|
||||
var err error
|
||||
cgrRpc, err = rpc.Dial("tcp", cfg.RPCGOBListen) //ToDo: Fix with automatic config
|
||||
//cgrRpc, err = rpc.Dial("tcp", cfg.RPCGOBListen) //ToDo: Fix with automatic config
|
||||
cgrRpc, err = jsonrpc.Dial("tcp", cfg.RPCJSONListen)
|
||||
if err != nil {
|
||||
t.Fatal("Could not connect to CGR GOB-RPC Server: ", err.Error())
|
||||
}
|
||||
|
||||
@@ -340,19 +340,19 @@ type AttrExpFileCdrs struct {
|
||||
MaskDestinationId *string // Overwrite configured MaskDestId
|
||||
MaskLength *int // Overwrite configured MaskLength, -1 to use general config ones
|
||||
CgrIds []string // If provided, it will filter based on the cgrids present in list
|
||||
MediationRunId []string // If provided, it will filter on mediation runid
|
||||
TOR []string // If provided, filter on TypeOfRecord
|
||||
CdrHost []string // If provided, it will filter cdrhost
|
||||
CdrSource []string // If provided, it will filter cdrsource
|
||||
ReqType []string // If provided, it will fiter reqtype
|
||||
Direction []string // If provided, it will fiter direction
|
||||
Tenant []string // If provided, it will filter tenant
|
||||
Category []string // If provided, it will filter çategory
|
||||
Account []string // If provided, it will filter account
|
||||
Subject []string // If provided, it will filter the rating subject
|
||||
DestinationPrefix []string // If provided, it will filter on destination prefix
|
||||
RatedAccount []string // If provided, it will filter ratedaccount
|
||||
RatedSubject []string // If provided, it will filter the ratedsubject
|
||||
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
|
||||
ReqTypes []string // If provided, it will fiter reqtype
|
||||
Directions []string // If provided, it will fiter direction
|
||||
Tenants []string // If provided, it will filter tenant
|
||||
Categories []string // If provided, it will filter çategory
|
||||
Accounts []string // If provided, it will filter account
|
||||
Subjects []string // If provided, it will filter the rating subject
|
||||
DestinationPrefixes []string // If provided, it will filter on destination prefix
|
||||
RatedAccounts []string // If provided, it will filter ratedaccount
|
||||
RatedSubjects []string // If provided, it will filter the ratedsubject
|
||||
OrderIdStart int64 // Export from this order identifier
|
||||
OrderIdEnd int64 // Export smaller than this order identifier
|
||||
TimeStart string // If provided, it will represent the starting of the CDRs interval (>=)
|
||||
@@ -372,26 +372,26 @@ type ExportedFileCdrs struct {
|
||||
}
|
||||
|
||||
type AttrGetCdrs struct {
|
||||
CgrIds []string // If provided, it will filter based on the cgrids present in list
|
||||
MediationRunId []string // If provided, it will filter on mediation runid
|
||||
TOR []string // If provided, filter on TypeOfRecord
|
||||
CdrHost []string // If provided, it will filter cdrhost
|
||||
CdrSource []string // If provided, it will filter cdrsource
|
||||
ReqType []string // If provided, it will fiter reqtype
|
||||
Direction []string // If provided, it will fiter direction
|
||||
Tenant []string // If provided, it will filter tenant
|
||||
Category []string // If provided, it will filter çategory
|
||||
Account []string // If provided, it will filter account
|
||||
Subject []string // If provided, it will filter the rating subject
|
||||
DestinationPrefix []string // If provided, it will filter on destination prefix
|
||||
RatedAccount []string // If provided, it will filter ratedaccount
|
||||
RatedSubject []string // If provided, it will filter the ratedsubject
|
||||
OrderIdStart int64 // Export from this order identifier
|
||||
OrderIdEnd int64 // Export smaller than this order identifier
|
||||
TimeStart string // If provided, it will represent the starting of the CDRs interval (>=)
|
||||
TimeEnd string // If provided, it will represent the end of the CDRs interval (<)
|
||||
SkipErrors bool // Do not export errored CDRs
|
||||
SkipRated bool // Do not export rated CDRs
|
||||
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
|
||||
ReqTypes []string // If provided, it will fiter reqtype
|
||||
Directions []string // If provided, it will fiter direction
|
||||
Tenants []string // If provided, it will filter tenant
|
||||
Categories []string // If provided, it will filter çategory
|
||||
Accounts []string // If provided, it will filter account
|
||||
Subjects []string // If provided, it will filter the rating subject
|
||||
DestinationPrefixes []string // If provided, it will filter on destination prefix
|
||||
RatedAccounts []string // If provided, it will filter ratedaccount
|
||||
RatedSubjects []string // If provided, it will filter the ratedsubject
|
||||
OrderIdStart int64 // Export from this order identifier
|
||||
OrderIdEnd int64 // Export smaller than this order identifier
|
||||
TimeStart string // If provided, it will represent the starting of the CDRs interval (>=)
|
||||
TimeEnd string // If provided, it will represent the end of the CDRs interval (<)
|
||||
SkipErrors bool // Do not export errored CDRs
|
||||
SkipRated bool // Do not export rated CDRs
|
||||
}
|
||||
|
||||
type AttrRemCdrs struct {
|
||||
@@ -399,10 +399,26 @@ type AttrRemCdrs struct {
|
||||
}
|
||||
|
||||
type AttrRateCdrs struct {
|
||||
TimeStart string // Cdrs time start
|
||||
TimeEnd string // Cdrs time end
|
||||
RerateErrors bool // Rerate previous CDRs with errors (makes sense for reqtype rated and pseudoprepaid
|
||||
RerateRated bool // Rerate CDRs which were previously rated (makes sense for reqtype rated and pseudoprepaid)
|
||||
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
|
||||
ReqTypes []string // If provided, it will fiter reqtype
|
||||
Directions []string // If provided, it will fiter direction
|
||||
Tenants []string // If provided, it will filter tenant
|
||||
Categories []string // If provided, it will filter çategory
|
||||
Accounts []string // If provided, it will filter account
|
||||
Subjects []string // If provided, it will filter the rating subject
|
||||
DestinationPrefixes []string // If provided, it will filter on destination prefix
|
||||
RatedAccounts []string // If provided, it will filter ratedaccount
|
||||
RatedSubjects []string // If provided, it will filter the ratedsubject
|
||||
OrderIdStart int64 // Export from this order identifier
|
||||
OrderIdEnd int64 // Export smaller than this order identifier
|
||||
TimeStart string // If provided, it will represent the starting of the CDRs interval (>=)
|
||||
TimeEnd string // If provided, it will represent the end of the CDRs interval (<)
|
||||
RerateErrors bool // Rerate previous CDRs with errors (makes sense for reqtype rated and pseudoprepaid
|
||||
RerateRated bool // Rerate CDRs which were previously rated (makes sense for reqtype rated and pseudoprepaid)
|
||||
}
|
||||
|
||||
type AttrLoadTpFromFolder struct {
|
||||
|
||||
Reference in New Issue
Block a user