mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
expiration time fixes
This commit is contained in:
@@ -208,6 +208,9 @@ func (at *ActionTiming) Execute() (err error) {
|
||||
}
|
||||
for _, a := range aac {
|
||||
a.ExpirationDate, _ = utils.ParseDate(a.ExpirationString)
|
||||
if a.MinuteBucket != nil {
|
||||
a.MinuteBucket.ExpirationDate = a.ExpirationDate
|
||||
}
|
||||
actionFunction, exists := getActionFunc(a.ActionType)
|
||||
if !exists {
|
||||
Logger.Crit(fmt.Sprintf("Function type %v not available, aborting execution!", a.ActionType))
|
||||
|
||||
@@ -47,6 +47,9 @@ func (at *ActionTrigger) Execute(ub *UserBalance) (err error) {
|
||||
}
|
||||
for _, a := range aac {
|
||||
a.ExpirationDate, _ = utils.ParseDate(a.ExpirationString)
|
||||
if a.MinuteBucket != nil {
|
||||
a.MinuteBucket.ExpirationDate = a.ExpirationDate
|
||||
}
|
||||
actionFunction, exists := getActionFunc(a.ActionType)
|
||||
if !exists {
|
||||
Logger.Warning(fmt.Sprintf("Function type %v not available, aborting execution!", a.ActionType))
|
||||
|
||||
@@ -381,12 +381,11 @@ func (csvr *CSVReader) LoadActions() (err error) {
|
||||
Weight: weight,
|
||||
ExpirationString: record[5],
|
||||
MinuteBucket: &MinuteBucket{
|
||||
Seconds: units,
|
||||
Weight: minutesWeight,
|
||||
Price: value,
|
||||
PriceType: record[7],
|
||||
DestinationId: record[6],
|
||||
ExpirationString: record[5],
|
||||
Seconds: units,
|
||||
Weight: minutesWeight,
|
||||
Price: value,
|
||||
PriceType: record[7],
|
||||
DestinationId: record[6],
|
||||
},
|
||||
}
|
||||
if _, err := utils.ParseDate(a.ExpirationString); err != nil {
|
||||
|
||||
@@ -25,14 +25,13 @@ import (
|
||||
)
|
||||
|
||||
type MinuteBucket struct {
|
||||
Seconds float64
|
||||
Weight float64
|
||||
Price float64 // percentage from standard price or absolute value depending on Type
|
||||
PriceType string
|
||||
DestinationId string
|
||||
ExpirationString string
|
||||
ExpirationDate time.Time
|
||||
precision int
|
||||
Seconds float64
|
||||
Weight float64
|
||||
Price float64 // percentage from standard price or absolute value depending on Type
|
||||
PriceType string
|
||||
DestinationId string
|
||||
ExpirationDate time.Time
|
||||
precision int
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -112,6 +112,7 @@ func (a *Action) Store() (result string, err error) {
|
||||
result += a.ActionType + "|"
|
||||
result += a.BalanceId + "|"
|
||||
result += a.Direction + "|"
|
||||
result += a.ExpirationString + "|"
|
||||
result += a.ExpirationDate.Format(time.RFC3339) + "|"
|
||||
result += strconv.FormatFloat(a.Units, 'f', -1, 64) + "|"
|
||||
result += strconv.FormatFloat(a.Weight, 'f', -1, 64)
|
||||
@@ -128,22 +129,23 @@ func (a *Action) Store() (result string, err error) {
|
||||
|
||||
func (a *Action) Restore(input string) (err error) {
|
||||
elements := strings.Split(input, "|")
|
||||
if len(elements) < 7 {
|
||||
if len(elements) < 8 {
|
||||
return notEnoughElements
|
||||
}
|
||||
a.Id = elements[0]
|
||||
a.ActionType = elements[1]
|
||||
a.BalanceId = elements[2]
|
||||
a.Direction = elements[3]
|
||||
a.ExpirationDate, err = time.Parse(time.RFC3339, elements[4])
|
||||
a.ExpirationString = elements[4]
|
||||
a.ExpirationDate, err = time.Parse(time.RFC3339, elements[5])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Units, _ = strconv.ParseFloat(elements[5], 64)
|
||||
a.Weight, _ = strconv.ParseFloat(elements[6], 64)
|
||||
if len(elements) == 8 {
|
||||
a.Units, _ = strconv.ParseFloat(elements[6], 64)
|
||||
a.Weight, _ = strconv.ParseFloat(elements[7], 64)
|
||||
if len(elements) == 9 {
|
||||
a.MinuteBucket = &MinuteBucket{}
|
||||
if err := a.MinuteBucket.Restore(elements[7]); err != nil {
|
||||
if err := a.MinuteBucket.Restore(elements[8]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1130,12 +1130,11 @@ func (self *SQLStorage) GetTpActions(tpid, tag string) (map[string][]*Action, er
|
||||
Weight: weight,
|
||||
ExpirationString: expirationDate,
|
||||
MinuteBucket: &MinuteBucket{
|
||||
Seconds: units,
|
||||
Weight: minutes_weight,
|
||||
Price: price,
|
||||
PriceType: rate_type,
|
||||
DestinationId: destinations_tag,
|
||||
ExpirationString: expirationDate,
|
||||
Seconds: units,
|
||||
Weight: minutes_weight,
|
||||
Price: price,
|
||||
PriceType: rate_type,
|
||||
DestinationId: destinations_tag,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user