From 6ecabf1d90703d7c7d3fc31ee517068bcadea574 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 10 Sep 2014 15:18:38 +0300 Subject: [PATCH] using _empty_ instead of *any for api --- apier/apier.go | 20 ++++++++++---------- apier/tpdestinations.go | 5 ++++- engine/account.go | 2 +- utils/consts.go | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/apier/apier.go b/apier/apier.go index ae51fdd3a..eec4c6d9c 100644 --- a/apier/apier.go +++ b/apier/apier.go @@ -211,7 +211,7 @@ func (self *ApierV1) LoadRatingPlan(attrs AttrLoadRatingPlan, reply *string) err if missing := utils.MissingStructFields(&attrs, []string{"TPid", "RatingPlanId"}); len(missing) != 0 { return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if attrs.RatingPlanId == utils.ANY { + if attrs.RatingPlanId == utils.EMPTY { attrs.RatingPlanId = "" } dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid) @@ -235,19 +235,19 @@ func (self *ApierV1) LoadRatingProfile(attrs utils.TPRatingProfile, reply *strin return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } - if attrs.LoadId == utils.ANY { + if attrs.LoadId == utils.EMPTY { attrs.LoadId = "" } - if attrs.Tenant == utils.ANY { + if attrs.Tenant == utils.EMPTY { attrs.Tenant = "" } - if attrs.Category == utils.ANY { + if attrs.Category == utils.EMPTY { attrs.Category = "" } - if attrs.Direction == utils.ANY { + if attrs.Direction == utils.EMPTY { attrs.Direction = "" } - if attrs.Subject == utils.ANY { + if attrs.Subject == utils.EMPTY { attrs.Subject = "" } @@ -608,16 +608,16 @@ func (self *ApierV1) LoadAccountActions(attrs utils.TPAccountActions, reply *str return fmt.Errorf("%s:%v", utils.ERR_MANDATORY_IE_MISSING, missing) } dbReader := engine.NewDbReader(self.StorDb, self.RatingDb, self.AccountDb, attrs.TPid) - if attrs.LoadId == utils.ANY { + if attrs.LoadId == utils.EMPTY { attrs.LoadId = "" } - if attrs.Tenant == utils.ANY { + if attrs.Tenant == utils.EMPTY { attrs.Tenant = "" } - if attrs.Account == utils.ANY { + if attrs.Account == utils.EMPTY { attrs.Account = "" } - if attrs.Direction == utils.ANY { + if attrs.Direction == utils.EMPTY { attrs.Direction = "" } if _, err := engine.AccLock.Guard(attrs.KeyId(), func() (float64, error) { diff --git a/apier/tpdestinations.go b/apier/tpdestinations.go index 26dee35c8..144791a87 100644 --- a/apier/tpdestinations.go +++ b/apier/tpdestinations.go @@ -53,7 +53,10 @@ func (self *ApierV1) GetTPDestination(attrs AttrGetTPDestination, reply *utils.T } else if len(dsts) == 0 { return errors.New(utils.ERR_NOT_FOUND) } else { - *reply = utils.TPDestination{attrs.TPid, dsts[attrs.DestinationId].Id, dsts[attrs.DestinationId].Prefixes} + *reply = utils.TPDestination{ + TPid: attrs.TPid, + DestinationId: dsts[attrs.DestinationId].Id, + Prefixes: dsts[attrs.DestinationId].Prefixes} } return nil } diff --git a/engine/account.go b/engine/account.go index bfec3a4dd..e0453043a 100644 --- a/engine/account.go +++ b/engine/account.go @@ -150,7 +150,7 @@ func (ub *Account) getBalancesForPrefix(prefix, category string, balances Balanc if b.IsExpired() || (ub.AllowNegative == false && b.SharedGroup == "" && b.Value <= 0) { continue } - if sharedGroup != "" && sharedGroup != "" && b.SharedGroup != sharedGroup { + if sharedGroup != "" && b.SharedGroup != sharedGroup { continue } if !b.MatchCategory(category) { diff --git a/utils/consts.go b/utils/consts.go index 45db833d1..b36d486aa 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -158,6 +158,7 @@ const ( CREATE_CDRS_TABLES_SQL = "create_cdrs_tables.sql" CREATE_TARIFFPLAN_TABLES_SQL = "create_tariffplan_tables.sql" TEST_SQL = "TEST_SQL" + EMPTY = "_empty_" ) var (