Added cdrs command in console

This commit is contained in:
Trial97
2020-07-31 09:56:51 +03:00
committed by Dan Christian Bogos
parent 0b7a258e73
commit fd2a5e0bc8
2 changed files with 68 additions and 4 deletions

65
console/cdrs.go Normal file
View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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
}

View File

@@ -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)