apier load fixes

This commit is contained in:
Radu Ioan Fericean
2015-08-12 15:41:14 +03:00
parent 345b9cd22a
commit 98a172ebbf
3 changed files with 21 additions and 12 deletions

View File

@@ -265,7 +265,11 @@ func (self *ApierV1) LoadRatingPlan(attrs AttrLoadRatingPlan, reply *string) err
//Automatic cache of the newly inserted rating plan
var changedRPlKeys []string
if len(attrs.TPid) != 0 {
changedRPlKeys = []string{utils.RATING_PLAN_PREFIX + attrs.RatingPlanId}
if attrs.RatingPlanId != "" {
changedRPlKeys = []string{utils.RATING_PLAN_PREFIX + attrs.RatingPlanId}
} else {
changedRPlKeys = nil
}
}
if err := self.RatingDb.CacheRatingPrefixValues(map[string][]string{
utils.DESTINATION_PREFIX: nil,

View File

@@ -81,7 +81,7 @@ func (self *ApierV2) LoadAccountActions(attrs AttrLoadAccountActions, 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.DERIVED_CHARGERS_CSV, utils.ACTION_PREFIX, utils.SHARED_GROUP_PREFIX); err != nil {
if err := self.RatingDb.CacheRatingPrefixes(utils.DERIVEDCHARGERS_PREFIX, utils.ACTION_PREFIX, utils.SHARED_GROUP_PREFIX); err != nil {
return err
}
if self.Sched != nil {

View File

@@ -681,17 +681,22 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *TpAccountAction) error
} else if len(actions) == 0 {
return fmt.Errorf("no action with id <%s>", at.ActionsId)
}
tptm, err := tpr.lr.GetTpTimings(tpr.tpid, at.TimingId)
if err != nil {
return errors.New(err.Error() + " (Timing): " + at.TimingId)
} else if len(tptm) == 0 {
return fmt.Errorf("no timing with id <%s>", at.TimingId)
var t *utils.TPTiming
if at.TimingId != utils.ASAP {
tptm, err := tpr.lr.GetTpTimings(tpr.tpid, at.TimingId)
if err != nil {
return errors.New(err.Error() + " (Timing): " + at.TimingId)
} else if len(tptm) == 0 {
return fmt.Errorf("no timing with id <%s>", at.TimingId)
}
tm, err := TpTimings(tptm).GetTimings()
if err != nil {
return err
}
t = tm[at.TimingId]
} else {
t = tpr.timings[at.TimingId] // *asap
}
tm, err := TpTimings(tptm).GetTimings()
if err != nil {
return err
}
t := tm[at.TimingId]
actTmg := &ActionPlan{
Uuid: utils.GenUUID(),
Id: accountAction.ActionPlanId,