mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
proposition for new timing tags *minute and *hour to be used in action
plans on recurring charges. NOTE: minute interval executes every second minute but logs from the scheduler report execution every minute
This commit is contained in:
@@ -95,7 +95,15 @@ func (at *ActionTiming) GetNextStartTime(now time.Time) (t time.Time) {
|
||||
if len(i.Timing.Months) > 0 && len(i.Timing.MonthDays) == 0 {
|
||||
i.Timing.MonthDays = append(i.Timing.MonthDays, 1)
|
||||
}
|
||||
at.stCache = cronexpr.MustParse(i.Timing.CronString()).Next(now)
|
||||
|
||||
if i.Timing.StartTime == utils.MINUTE {
|
||||
at.stCache = cronexpr.MustParse("0 * * * * * *").Next(now)
|
||||
} else if i.Timing.StartTime == utils.HOUR {
|
||||
at.stCache = cronexpr.MustParse("0 0 * * * * *").Next(now)
|
||||
} else {
|
||||
at.stCache = cronexpr.MustParse(i.Timing.CronString()).Next(now)
|
||||
}
|
||||
|
||||
return at.stCache
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,24 @@ func NewTpReader(db DataDB, lr LoadReader, tpid, timezone string) *TpReader {
|
||||
StartTime: utils.ASAP,
|
||||
EndTime: "",
|
||||
}
|
||||
tpr.timings[utils.MINUTE] = &utils.TPTiming{
|
||||
ID: utils.MINUTE,
|
||||
Years: utils.Years{},
|
||||
Months: utils.Months{},
|
||||
MonthDays: utils.MonthDays{},
|
||||
WeekDays: utils.WeekDays{},
|
||||
StartTime: utils.MINUTE,
|
||||
EndTime: "",
|
||||
}
|
||||
tpr.timings[utils.HOUR] = &utils.TPTiming{
|
||||
ID: utils.HOUR,
|
||||
Years: utils.Years{},
|
||||
Months: utils.Months{},
|
||||
MonthDays: utils.MonthDays{},
|
||||
WeekDays: utils.WeekDays{},
|
||||
StartTime: utils.HOUR,
|
||||
EndTime: "",
|
||||
}
|
||||
return tpr
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,8 @@ const (
|
||||
UNLIMITED = "*unlimited"
|
||||
ZERO = "*zero"
|
||||
ASAP = "*asap"
|
||||
MINUTE = "*minute"
|
||||
HOUR = "*hour"
|
||||
USERS = "*users"
|
||||
COMMENT_CHAR = '#'
|
||||
CSV_SEP = ','
|
||||
|
||||
@@ -102,5 +102,21 @@ func incrementalFormula(params map[string]interface{}) float64 {
|
||||
return units / DaysInYear(now.Year())
|
||||
}
|
||||
}
|
||||
if increment == "hour" {
|
||||
if interval == "day" {
|
||||
return units / 24
|
||||
}
|
||||
if interval == "month" {
|
||||
return units / ( DaysInMonth(now.Year(), now.Month()) * 24 )
|
||||
}
|
||||
if interval == "year" {
|
||||
return units / ( DaysInYear(now.Year()) * 24 )
|
||||
}
|
||||
}
|
||||
if increment == "minute" {
|
||||
if interval == "hour" {
|
||||
return units / 60
|
||||
}
|
||||
}
|
||||
return 0.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user