diff --git a/apier/tpaccountactions.go b/apier/tpaccountactions.go index a3a52da22..2f2b539da 100644 --- a/apier/tpaccountactions.go +++ b/apier/tpaccountactions.go @@ -80,7 +80,7 @@ func (self *ApierV1) GetTPAccountActionLoadIds(attrs AttrGetTPAccountActionIds, if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTIONS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTIONS, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpactions.go b/apier/tpactions.go index a623929ec..3e62abbed 100644 --- a/apier/tpactions.go +++ b/apier/tpactions.go @@ -75,7 +75,7 @@ func (self *ApierV1) GetTPActionIds(attrs AttrGetTPActionIds, reply *[]string) e if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTIONS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTIONS, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpactiontimings.go b/apier/tpactiontimings.go index 199d0c76b..f895c2839 100644 --- a/apier/tpactiontimings.go +++ b/apier/tpactiontimings.go @@ -73,7 +73,7 @@ func (self *ApierV1) GetTPActionPlanIds(attrs AttrGetTPActionPlanIds, reply *[]s if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_PLANS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_PLANS, "", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpactiontriggers.go b/apier/tpactiontriggers.go index d3429a8c6..982b438dd 100644 --- a/apier/tpactiontriggers.go +++ b/apier/tpactiontriggers.go @@ -71,7 +71,7 @@ func (self *ApierV1) GetTPActionTriggerIds(attrs AttrGetTPActionTriggerIds, repl if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_TRIGGERS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_ACTION_TRIGGERS, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpdestinationrates.go b/apier/tpdestinationrates.go index 9ac01df71..636d7693d 100644 --- a/apier/tpdestinationrates.go +++ b/apier/tpdestinationrates.go @@ -68,7 +68,7 @@ func (self *ApierV1) GetTPDestinationRateIds(attrs AttrGetTPRateIds, reply *[]st if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATION_RATES, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATION_RATES, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpdestinations.go b/apier/tpdestinations.go index 163809f89..bb42630b8 100644 --- a/apier/tpdestinations.go +++ b/apier/tpdestinations.go @@ -67,7 +67,7 @@ func (self *ApierV1) GetTPDestinationIds(attrs AttrGetTPDestinationIds, reply *[ if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATIONS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_DESTINATIONS, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tprates.go b/apier/tprates.go index 13a24eecf..2e812dd82 100644 --- a/apier/tprates.go +++ b/apier/tprates.go @@ -68,7 +68,7 @@ func (self *ApierV1) GetTPRateIds(attrs AttrGetTPRateIds, reply *[]string) error if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATES, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATES, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpratingplans.go b/apier/tpratingplans.go index 74a04d510..70496f306 100644 --- a/apier/tpratingplans.go +++ b/apier/tpratingplans.go @@ -68,7 +68,7 @@ func (self *ApierV1) GetTPRatingPlanIds(attrs AttrGetTPRatingPlanIds, reply *[]s if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATING_PLANS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATING_PLANS, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/apier/tpratingprofiles.go b/apier/tpratingprofiles.go index db2c8393e..fb91b875e 100644 --- a/apier/tpratingprofiles.go +++ b/apier/tpratingprofiles.go @@ -76,7 +76,7 @@ func (self *ApierV1) GetTPRatingProfileLoadIds(attrs utils.AttrTPRatingProfileId if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATE_PROFILES, map[string]string{ + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_RATE_PROFILES, "loadid", map[string]string{ "tenant": attrs.Tenant, "tor": attrs.TOR, "direction": attrs.Direction, diff --git a/apier/tptimings.go b/apier/tptimings.go index fcd2cc856..5fa316f2a 100644 --- a/apier/tptimings.go +++ b/apier/tptimings.go @@ -70,7 +70,7 @@ func (self *ApierV1) GetTPTimingIds(attrs AttrGetTPTimingIds, reply *[]string) e if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_TIMINGS, nil); err != nil { + if ids, err := self.StorDb.GetTPTableIds(attrs.TPid, utils.TBL_TP_TIMINGS, "tag", nil); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) } else if ids == nil { return errors.New(utils.ERR_NOT_FOUND) diff --git a/engine/storage_interface.go b/engine/storage_interface.go index 01545053f..d98fa11dd 100644 --- a/engine/storage_interface.go +++ b/engine/storage_interface.go @@ -117,7 +117,7 @@ type LoadStorage interface { // Apier functions RemTPData(string, string, ...string) error GetTPIds() ([]string, error) - GetTPTableIds(string, string, map[string]string) ([]string, error) + GetTPTableIds(string, string, string, map[string]string) ([]string, error) SetTPTiming(string, *utils.TPTiming) error GetTpTimings(string, string) (map[string]*utils.TPTiming, error) diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 0a140920b..aa418e87e 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -85,8 +85,8 @@ func (self *SQLStorage) GetTPIds() ([]string, error) { return ids, nil } -func (self *SQLStorage) GetTPTableIds(tpid, table string, filters map[string]string) ([]string, error) { - qry := fmt.Sprintf("SELECT DISTINCT tag FROM %s where tpid='%s'", table, tpid) +func (self *SQLStorage) GetTPTableIds(tpid, table, distinct string, filters map[string]string) ([]string, error) { + qry := fmt.Sprintf("SELECT DISTINCT %s FROM %s where tpid='%s'", distinct, table, tpid) for key, value := range filters { if key != "" && value != "" { qry += fmt.Sprintf(" AND %s='%s'", key, value) @@ -936,7 +936,7 @@ func (self *SQLStorage) GetTpActions(tpid, tag string) (map[string][]*utils.TPAc ExpiryTime: expirationDate, DestinationId: destinations_tag, RatingSubject: rating_subject, - SharedGroup: shared_group, + SharedGroup: shared_group, BalanceWeight: balance_weight, ExtraParameters: extra_parameters, Weight: weight,