diff --git a/console/cdrs.go b/console/cdrs.go new file mode 100644 index 000000000..8b3c93604 --- /dev/null +++ b/console/cdrs.go @@ -0,0 +1,65 @@ +/* +Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments +Copyright (C) ITsysCOM GmbH + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ + +package console + +import ( + "github.com/cgrates/cgrates/engine" + "github.com/cgrates/cgrates/utils" +) + +func init() { + c := &CmdGetCDRs{ + name: "cdrs", + rpcMethod: utils.CDRsV1GetCDRs, + } + commands[c.Name()] = c + c.CommandExecuter = &CommandExecuter{c} +} + +// Commander implementation +type CmdGetCDRs struct { + name string + rpcMethod string + rpcParams *utils.RPCCDRsFilterWithOpts + *CommandExecuter +} + +func (self *CmdGetCDRs) Name() string { + return self.name +} + +func (self *CmdGetCDRs) RpcMethod() string { + return self.rpcMethod +} + +func (self *CmdGetCDRs) RpcParams(reset bool) interface{} { + if reset || self.rpcParams == nil { + self.rpcParams = &utils.RPCCDRsFilterWithOpts{} + } + return self.rpcParams +} + +func (self *CmdGetCDRs) PostprocessRpcParams() error { + return nil +} + +func (self *CmdGetCDRs) RpcResult() interface{} { + a := make([]*engine.CDR, 0) + return &a +} diff --git a/engine/cdrs.go b/engine/cdrs.go index 42d4b63c5..53a848ec0 100644 --- a/engine/cdrs.go +++ b/engine/cdrs.go @@ -778,8 +778,7 @@ func (cdrS *CDRServer) V1ProcessEvent(arg *ArgV1ProcessEvent, reply *string) (er } var reRate bool if flgs.Has(utils.MetaRerate) { - reRate = flgs.GetBool(utils.MetaRerate) - if reRate { + if reRate = flgs.GetBool(utils.MetaRerate); reRate { ralS = true } } @@ -984,8 +983,8 @@ func (cdrS *CDRServer) V1RateCDRs(arg *ArgRateCDRs, reply *string) (err error) { if cdrFltr, err = arg.RPCCDRsFilter.AsCDRsFilter(cdrS.cgrCfg.GeneralCfg().DefaultTimezone); err != nil { return utils.NewErrServerError(err) } - cdrs, _, err := cdrS.cdrDb.GetCDRs(cdrFltr, false) - if err != nil { + var cdrs []*CDR + if cdrs, _, err = cdrS.cdrDb.GetCDRs(cdrFltr, false); err != nil { return } flgs := utils.FlagsWithParamsFromSlice(arg.Flags)