mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 05:09:54 +05:00
Add Clone function for *decimal.Big types and fix load function in attributescfg file
This commit is contained in:
committed by
Dan Christian Bogos
parent
a3290f519e
commit
9cf65cde89
@@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
@@ -49,24 +47,9 @@ func (attrOpts *AttributesOpts) loadFromJSONCfg(jsnCfg *AttributesOptsJson) (err
|
||||
if jsnCfg == nil {
|
||||
return
|
||||
}
|
||||
for filters, value := range jsnCfg.AttributeIDs {
|
||||
attrOpts.AttributeIDs = append(attrOpts.AttributeIDs, &utils.DynamicStringSliceOpt{
|
||||
FilterIDs: strings.Split(filters, utils.InfieldSep),
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
for filters, value := range jsnCfg.ProcessRuns {
|
||||
attrOpts.ProcessRuns = append(attrOpts.ProcessRuns, &utils.DynamicIntOpt{
|
||||
FilterIDs: strings.Split(filters, utils.InfieldSep),
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
for filters, value := range jsnCfg.ProfileRuns {
|
||||
attrOpts.ProfileRuns = append(attrOpts.ProfileRuns, &utils.DynamicIntOpt{
|
||||
FilterIDs: strings.Split(filters, utils.InfieldSep),
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
attrOpts.AttributeIDs = utils.MapToDynamicStringSliceOpts(jsnCfg.AttributeIDs)
|
||||
attrOpts.ProcessRuns = utils.MapToDynamicIntOpts(jsnCfg.ProcessRuns)
|
||||
attrOpts.ProfileRuns = utils.MapToDynamicIntOpts(jsnCfg.ProfileRuns)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -375,6 +375,21 @@ func MapToDynamicBoolOpts(optsMap map[string]bool) (dynOpts []*DynamicBoolOpt) {
|
||||
return
|
||||
}
|
||||
|
||||
func MapToDynamicIntOpts(optsMap map[string]int) (dynOpts []*DynamicIntOpt) {
|
||||
dynOpts = make([]*DynamicIntOpt, 0, len(optsMap))
|
||||
for filters, opt := range optsMap {
|
||||
var filterIDs []string
|
||||
if filters != EmptyString {
|
||||
filterIDs = strings.Split(filters, InfieldSep)
|
||||
}
|
||||
dynOpts = append(dynOpts, &DynamicIntOpt{
|
||||
FilterIDs: filterIDs,
|
||||
Value: opt,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func MapToDynamicDecimalBigOpts(optsMap map[string]string) (dynOpts []*DynamicDecimalBigOpt, err error) {
|
||||
dynOpts = make([]*DynamicDecimalBigOpt, 0, len(optsMap))
|
||||
for filters, opt := range optsMap {
|
||||
@@ -444,6 +459,7 @@ func MapToDynamicInterfaceOpts(optsMap map[string]string) (dynOpts []*DynamicInt
|
||||
}
|
||||
|
||||
func CloneDecimalBig(in *decimal.Big) (cln *decimal.Big) {
|
||||
*cln = *in
|
||||
cln = new(decimal.Big)
|
||||
cln.Copy(in)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user