mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
rename ActionTimings Tag and Id
This commit is contained in:
@@ -35,7 +35,7 @@ type AttrAcntAction struct {
|
||||
|
||||
type AccountActionTiming struct {
|
||||
ActionPlanId string // The id of the ActionPlanId profile attached to the account
|
||||
Id string // The id to reference this particular ActionTiming
|
||||
Uuid string // The id to reference this particular ActionTiming
|
||||
ActionsId string // The id of actions which will be executed
|
||||
NextExecTime time.Time // Next execution time
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func (self *ApierV1) GetAccountActionPlan(attrs AttrAcntAction, reply *[]*Accoun
|
||||
for _, ats := range allATs {
|
||||
for _, at := range ats {
|
||||
if utils.IsSliceMember(at.AccountIds, utils.BalanceKey(attrs.Tenant, attrs.Account, attrs.Direction)) {
|
||||
accountATs = append(accountATs, &AccountActionTiming{Id: at.Id, ActionPlanId: at.Tag, ActionsId: at.ActionsId, NextExecTime: at.GetNextStartTime(time.Now())})
|
||||
accountATs = append(accountATs, &AccountActionTiming{Uuid: at.Uuid, ActionPlanId: at.Id, ActionsId: at.ActionsId, NextExecTime: at.GetNextStartTime(time.Now())})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,8 +360,8 @@ func (self *ApierV1) SetActionPlan(attrs AttrSetActionPlan, reply *string) error
|
||||
timing.WeekDays.Parse(apiAtm.WeekDays, ";")
|
||||
timing.StartTime = apiAtm.Time
|
||||
at := &engine.ActionTiming{
|
||||
Id: utils.GenUUID(),
|
||||
Tag: attrs.Id,
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: attrs.Id,
|
||||
Weight: apiAtm.Weight,
|
||||
Timing: &engine.RateInterval{Timing: timing},
|
||||
ActionsId: apiAtm.ActionsId,
|
||||
|
||||
@@ -385,6 +385,9 @@ func TestMaxCallDuration(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMaxDebit1001(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
cc := &engine.CallCost{}
|
||||
var acnt *engine.Account
|
||||
cd := engine.CallDescriptor{
|
||||
@@ -421,6 +424,9 @@ func TestMaxDebit1001(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMaxDebit1007(t *testing.T) {
|
||||
if !*testLocal {
|
||||
return
|
||||
}
|
||||
cc := &engine.CallCost{}
|
||||
var acnt *engine.Account
|
||||
cd := engine.CallDescriptor{
|
||||
|
||||
@@ -35,8 +35,8 @@ const (
|
||||
)
|
||||
|
||||
type ActionTiming struct {
|
||||
Id string // uniquely identify the timing
|
||||
Tag string // informative purpose only
|
||||
Uuid string // uniquely identify the timing
|
||||
Id string // informative purpose only
|
||||
AccountIds []string
|
||||
Timing *RateInterval
|
||||
Weight float64
|
||||
@@ -301,13 +301,13 @@ func (atpl ActionTimingPriotityList) Sort() {
|
||||
}
|
||||
|
||||
func (at *ActionTiming) String_DISABLED() string {
|
||||
return at.Tag + " " + at.GetNextStartTime(time.Now()).String() + ",w: " + strconv.FormatFloat(at.Weight, 'f', -1, 64)
|
||||
return at.Id + " " + at.GetNextStartTime(time.Now()).String() + ",w: " + strconv.FormatFloat(at.Weight, 'f', -1, 64)
|
||||
}
|
||||
|
||||
// Helper to remove ActionTiming members based on specific filters, empty data means no always match
|
||||
func RemActionTiming(ats ActionPlan, actionTimingId, balanceId string) ActionPlan {
|
||||
for idx, at := range ats {
|
||||
if len(actionTimingId) != 0 && at.Id != actionTimingId { // No Match for ActionTimingId, no need to move further
|
||||
if len(actionTimingId) != 0 && at.Uuid != actionTimingId { // No Match for ActionTimingId, no need to move further
|
||||
continue
|
||||
}
|
||||
if len(balanceId) == 0 { // No account defined, considered match for complete removal
|
||||
|
||||
@@ -431,14 +431,14 @@ func TestActionTimingPriotityListWeight(t *testing.T) {
|
||||
|
||||
func TestActionTimingsRemoveMember(t *testing.T) {
|
||||
at1 := &ActionTiming{
|
||||
Id: "some uuid",
|
||||
Tag: "test",
|
||||
Uuid: "some uuid",
|
||||
Id: "test",
|
||||
AccountIds: []string{"one", "two", "three"},
|
||||
ActionsId: "TEST_ACTIONS",
|
||||
}
|
||||
at2 := &ActionTiming{
|
||||
Id: "some uuid22",
|
||||
Tag: "test2",
|
||||
Uuid: "some uuid22",
|
||||
Id: "test2",
|
||||
AccountIds: []string{"three", "four"},
|
||||
ActionsId: "TEST_ACTIONS2",
|
||||
}
|
||||
@@ -916,8 +916,8 @@ func TestActionTimingLogging(t *testing.T) {
|
||||
},
|
||||
}
|
||||
at := &ActionTiming{
|
||||
Id: "some uuid",
|
||||
Tag: "test",
|
||||
Uuid: "some uuid",
|
||||
Id: "test",
|
||||
AccountIds: []string{"one", "two", "three"},
|
||||
Timing: i,
|
||||
Weight: 10.0,
|
||||
|
||||
@@ -619,8 +619,8 @@ func (csvr *CSVReader) LoadActionTimings() (err error) {
|
||||
return fmt.Errorf("ActionTiming: Could not parse action timing weight: %v", err)
|
||||
}
|
||||
at := &ActionTiming{
|
||||
Id: utils.GenUUID(),
|
||||
Tag: record[0],
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: record[0],
|
||||
Weight: weight,
|
||||
Timing: &RateInterval{
|
||||
Timing: &RITiming{
|
||||
|
||||
@@ -719,8 +719,8 @@ func TestLoadActionTimings(t *testing.T) {
|
||||
}
|
||||
atm := csvr.actionsTimings["MORE_MINUTES"][0]
|
||||
expected := &ActionTiming{
|
||||
Id: atm.Id,
|
||||
Tag: "MORE_MINUTES",
|
||||
Uuid: atm.Uuid,
|
||||
Id: "MORE_MINUTES",
|
||||
AccountIds: []string{"*out:vdf:minitsboy"},
|
||||
Timing: &RateInterval{
|
||||
Timing: &RITiming{
|
||||
|
||||
@@ -488,8 +488,8 @@ func (dbr *DbReader) LoadActionTimings() (err error) {
|
||||
return fmt.Errorf("ActionTiming: Could not load the timing for tag: %v", at.TimingId)
|
||||
}
|
||||
actTmg := &ActionTiming{
|
||||
Id: utils.GenUUID(),
|
||||
Tag: atId,
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: atId,
|
||||
Weight: at.Weight,
|
||||
Timing: &RateInterval{
|
||||
Timing: &RITiming{
|
||||
@@ -612,8 +612,8 @@ func (dbr *DbReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
|
||||
}
|
||||
t := timingsMap[at.TimingId]
|
||||
actTmg := &ActionTiming{
|
||||
Id: utils.GenUUID(),
|
||||
Tag: accountAction.ActionPlanId,
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: accountAction.ActionPlanId,
|
||||
Weight: at.Weight,
|
||||
Timing: &RateInterval{
|
||||
Timing: &RITiming{
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s *Scheduler) Loop() {
|
||||
a0 := s.queue[0]
|
||||
now := time.Now()
|
||||
if a0.GetNextStartTime(now).Equal(now) || a0.GetNextStartTime(now).Before(now) {
|
||||
engine.Logger.Debug(fmt.Sprintf("%v - %v", a0.Tag, a0.Timing))
|
||||
engine.Logger.Debug(fmt.Sprintf("%v - %v", a0.Id, a0.Timing))
|
||||
go a0.Execute()
|
||||
s.queue = append(s.queue, a0)
|
||||
s.queue = s.queue[1:]
|
||||
|
||||
Reference in New Issue
Block a user