write tasks on loadaccountactions

This commit is contained in:
Radu Ioan Fericean
2015-12-18 17:48:03 +02:00
parent c18d2ce2ba
commit 115fe8a1ad
3 changed files with 17 additions and 2 deletions

View File

@@ -806,7 +806,7 @@ func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *str
}
// ToDo: Get the action keys loaded by dbReader so we reload only these in cache
// Need to do it before scheduler otherwise actions to run will be unknown
if err := self.RatingDb.CacheRatingPrefixes(utils.DERIVEDCHARGERS_PREFIX, utils.ACTION_PREFIX, utils.SHARED_GROUP_PREFIX); err != nil {
if err := self.RatingDb.CacheRatingPrefixes(utils.DERIVEDCHARGERS_PREFIX, utils.ACTION_PREFIX, utils.SHARED_GROUP_PREFIX, utils.ACTION_PLAN_PREFIX); err != nil {
return err
}
if self.Sched != nil {

View File

@@ -732,6 +732,21 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *TpAccountAction) error
actionPlan.AccountIDs = exitingAccountIds
}
// write tasks
for _, at := range actionPlan.ActionTimings {
if at.IsASAP() {
for accID := range actionPlan.AccountIDs {
t := &Task{
Uuid: utils.GenUUID(),
AccountID: accID,
ActionsID: at.ActionsID,
}
if err = tpr.ratingStorage.PushTask(t); err != nil {
return err
}
}
}
}
// write action plan
err = tpr.ratingStorage.SetActionPlan(accountAction.ActionPlanId, actionPlan)
if err != nil {

View File

@@ -96,7 +96,7 @@ func (s *Scheduler) loadActionPlans() {
s.Lock()
defer s.Unlock()
// limit the number of concurrent tasks
var limit = make(chan bool, 10)
limit := make(chan bool, 10)
// execute existing tasks
for {
task, err := s.storage.PopTask()