mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
Correctly naming TBLTPRatingProfile constant
This commit is contained in:
committed by
Dan Christian Bogos
parent
9c9e35857f
commit
5ebd347612
@@ -62,7 +62,7 @@ func (api *APIerSv1) GetTPRatingProfileLoadIds(attrs *utils.AttrTPRatingProfileI
|
||||
if missing := utils.MissingStructFields(attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
ids, err := api.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPRateProfiles,
|
||||
ids, err := api.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPRatingProfiles,
|
||||
utils.TPDistinctIds{"loadid"}, map[string]string{
|
||||
"tenant": attrs.Tenant,
|
||||
"category": attrs.Category,
|
||||
@@ -115,7 +115,7 @@ func (api *APIerSv1) GetTPRatingProfileIds(attrs *AttrGetTPRatingProfileIds, rep
|
||||
if missing := utils.MissingStructFields(attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
ids, err := api.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPRateProfiles,
|
||||
ids, err := api.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPRatingProfiles,
|
||||
utils.TPDistinctIds{"loadid", "tenant", "category", "subject"},
|
||||
nil, &attrs.PaginatorWithSearch)
|
||||
if err != nil {
|
||||
@@ -137,7 +137,7 @@ func (api *APIerSv1) RemoveTPRatingProfile(attrs *AttrGetTPRatingProfile, reply
|
||||
if err = tmpRpf.SetRatingProfileID(attrs.RatingProfileID); err != nil {
|
||||
return
|
||||
}
|
||||
err = api.StorDb.RemTpData(utils.TBLTPRateProfiles,
|
||||
err = api.StorDb.RemTpData(utils.TBLTPRatingProfiles,
|
||||
attrs.TPid, map[string]string{
|
||||
"loadid": tmpRpf.LoadId,
|
||||
"tenant": tmpRpf.Tenant,
|
||||
|
||||
@@ -434,7 +434,7 @@ func TestDfStorDBJsonCfg(t *testing.T) {
|
||||
Ttl: utils.StringPointer(utils.EmptyString),
|
||||
Limit: utils.IntPointer(-1),
|
||||
Static_ttl: utils.BoolPointer(false)},
|
||||
utils.TBLTPRateProfiles: {
|
||||
utils.TBLTPRatingProfiles: {
|
||||
Ttl: utils.StringPointer(utils.EmptyString),
|
||||
Limit: utils.IntPointer(-1),
|
||||
Static_ttl: utils.BoolPointer(false)},
|
||||
|
||||
@@ -223,10 +223,10 @@ func newInternalDBCfg(itemsCacheCfg map[string]*config.ItemOpt, isDataDB bool) m
|
||||
TTL: itemsCacheCfg[utils.TBLTPRatingPlans].TTL,
|
||||
StaticTTL: itemsCacheCfg[utils.TBLTPRatingPlans].StaticTTL,
|
||||
},
|
||||
utils.TBLTPRateProfiles: <cache.CacheConfig{
|
||||
MaxItems: itemsCacheCfg[utils.TBLTPRateProfiles].Limit,
|
||||
TTL: itemsCacheCfg[utils.TBLTPRateProfiles].TTL,
|
||||
StaticTTL: itemsCacheCfg[utils.TBLTPRateProfiles].StaticTTL,
|
||||
utils.TBLTPRatingProfiles: <cache.CacheConfig{
|
||||
MaxItems: itemsCacheCfg[utils.TBLTPRatingProfiles].Limit,
|
||||
TTL: itemsCacheCfg[utils.TBLTPRatingProfiles].TTL,
|
||||
StaticTTL: itemsCacheCfg[utils.TBLTPRatingProfiles].StaticTTL,
|
||||
},
|
||||
utils.TBLTPSharedGroups: <cache.CacheConfig{
|
||||
MaxItems: itemsCacheCfg[utils.TBLTPSharedGroups].Limit,
|
||||
|
||||
@@ -55,7 +55,7 @@ func (iDB *InternalDB) GetTpTableIds(tpid, table string, distinct utils.TPDistin
|
||||
switch table {
|
||||
// in case of account action <loadid:tenant:account> and rating profile <loadid:tenant:category:subject>
|
||||
// the retutned value may be only the loadID
|
||||
case utils.TBLTPAccountActions, utils.TBLTPRateProfiles:
|
||||
case utils.TBLTPAccountActions, utils.TBLTPRatingProfiles:
|
||||
if len(distinct) == 1 { // special case when to return only the loadID
|
||||
sliceID := strings.Split(fullID[len(tpid)+1:], utils.CONCATENATED_KEY_SEP)
|
||||
idSet.Add(sliceID[0])
|
||||
@@ -239,9 +239,9 @@ func (iDB *InternalDB) GetTPRatingProfiles(filter *utils.TPRatingProfile) (rProf
|
||||
if filter.Subject != utils.EmptyString {
|
||||
key += utils.CONCATENATED_KEY_SEP + filter.Subject
|
||||
}
|
||||
ids := iDB.db.GetItemIDs(utils.TBLTPRateProfiles, key)
|
||||
ids := iDB.db.GetItemIDs(utils.TBLTPRatingProfiles, key)
|
||||
for _, id := range ids {
|
||||
x, ok := iDB.db.Get(utils.TBLTPRateProfiles, id)
|
||||
x, ok := iDB.db.Get(utils.TBLTPRatingProfiles, id)
|
||||
if !ok || x == nil {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
@@ -644,7 +644,7 @@ func (iDB *InternalDB) SetTPRatingProfiles(ratingProfiles []*utils.TPRatingProfi
|
||||
return nil
|
||||
}
|
||||
for _, rProfile := range ratingProfiles {
|
||||
iDB.db.Set(utils.TBLTPRateProfiles, utils.ConcatenatedKey(rProfile.TPid,
|
||||
iDB.db.Set(utils.TBLTPRatingProfiles, utils.ConcatenatedKey(rProfile.TPid,
|
||||
rProfile.LoadId, rProfile.Tenant, rProfile.Category, rProfile.Subject), rProfile, nil,
|
||||
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ func (ms *MongoStorage) ensureIndexesForCol(col string) (err error) { // exporte
|
||||
if err = ms.enusureIndex(col, true, "tpid", "id"); err != nil {
|
||||
return
|
||||
}
|
||||
case utils.TBLTPRateProfiles:
|
||||
case utils.TBLTPRatingProfiles:
|
||||
if err = ms.enusureIndex(col, true, "tpid", "tenant",
|
||||
"category", "subject", "loadid"); err != nil {
|
||||
return
|
||||
@@ -363,7 +363,7 @@ func (ms *MongoStorage) EnsureIndexes(cols ...string) (err error) {
|
||||
utils.TBLTPSharedGroups, utils.TBLTPActions,
|
||||
utils.TBLTPActionPlans, utils.TBLTPActionTriggers,
|
||||
utils.TBLTPStats, utils.TBLTPResources,
|
||||
utils.TBLTPRateProfiles, utils.CDRsTBL, utils.SessionCostsTBL} {
|
||||
utils.TBLTPRatingProfiles, utils.CDRsTBL, utils.SessionCostsTBL} {
|
||||
if err = ms.ensureIndexesForCol(col); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ func (ms *MongoStorage) GetTPRatingProfiles(tp *utils.TPRatingProfile) ([]*utils
|
||||
}
|
||||
var results []*utils.TPRatingProfile
|
||||
err := ms.query(func(sctx mongo.SessionContext) (err error) {
|
||||
cur, err := ms.getCol(utils.TBLTPRateProfiles).Find(sctx, filter)
|
||||
cur, err := ms.getCol(utils.TBLTPRatingProfiles).Find(sctx, filter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -706,7 +706,7 @@ func (ms *MongoStorage) SetTPRatingProfiles(tps []*utils.TPRatingProfile) error
|
||||
}
|
||||
return ms.query(func(sctx mongo.SessionContext) (err error) {
|
||||
for _, tp := range tps {
|
||||
_, err = ms.getCol(utils.TBLTPRateProfiles).UpdateOne(sctx, bson.M{
|
||||
_, err = ms.getCol(utils.TBLTPRatingProfiles).UpdateOne(sctx, bson.M{
|
||||
"tpid": tp.TPid,
|
||||
"loadid": tp.LoadId,
|
||||
"tenant": tp.Tenant,
|
||||
|
||||
@@ -100,7 +100,7 @@ func (self *SQLStorage) CreateTablesFromScript(scriptPath string) error {
|
||||
func (self *SQLStorage) IsDBEmpty() (resp bool, err error) {
|
||||
tbls := []string{
|
||||
utils.TBLTPTimings, utils.TBLTPDestinations, utils.TBLTPRates,
|
||||
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRateProfiles,
|
||||
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRatingProfiles,
|
||||
utils.TBLTPSharedGroups, utils.TBLTPActions, utils.TBLTPActionTriggers,
|
||||
utils.TBLTPAccountActions, utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPThresholds,
|
||||
utils.TBLTPFilters, utils.SessionCostsTBL, utils.CDRsTBL, utils.TBLTPActionPlans,
|
||||
@@ -130,7 +130,7 @@ func (self *SQLStorage) GetTpIds(colName string) ([]string, error) {
|
||||
utils.TBLTPRates,
|
||||
utils.TBLTPDestinationRates,
|
||||
utils.TBLTPRatingPlans,
|
||||
utils.TBLTPRateProfiles,
|
||||
utils.TBLTPRatingProfiles,
|
||||
utils.TBLTPSharedGroups,
|
||||
utils.TBLTPActions,
|
||||
utils.TBLTPActionTriggers,
|
||||
@@ -234,7 +234,7 @@ func (self *SQLStorage) RemTpData(table, tpid string, args map[string]string) er
|
||||
|
||||
if len(table) == 0 { // Remove tpid out of all tables
|
||||
for _, tblName := range []string{utils.TBLTPTimings, utils.TBLTPDestinations, utils.TBLTPRates,
|
||||
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRateProfiles,
|
||||
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRatingProfiles,
|
||||
utils.TBLTPSharedGroups, utils.TBLTPActions, utils.TBLTPActionPlans,
|
||||
utils.TBLTPActionTriggers, utils.TBLTPAccountActions,
|
||||
utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPFilters,
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
func (m *Migrator) migrateCurrentTPratingprofiles() (err error) {
|
||||
|
||||
tpids, err := m.storDBIn.StorDB().GetTpIds(utils.TBLTPRateProfiles)
|
||||
tpids, err := m.storDBIn.StorDB().GetTpIds(utils.TBLTPRatingProfiles)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -43,7 +43,7 @@ func (m *Migrator) migrateCurrentTPratingprofiles() (err error) {
|
||||
return err
|
||||
}
|
||||
for _, ratPrf := range ratingProfile {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPRateProfiles, ratPrf.TPid,
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPRatingProfiles, ratPrf.TPid,
|
||||
map[string]string{"loadid": ratPrf.LoadId,
|
||||
"tenant": ratPrf.Tenant, "category": ratPrf.Category,
|
||||
"subject": ratPrf.Subject}); err != nil {
|
||||
@@ -81,5 +81,5 @@ func (m *Migrator) migrateTPratingprofiles() (err error) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return m.ensureIndexesStorDB(utils.TBLTPRateProfiles)
|
||||
return m.ensureIndexesStorDB(utils.TBLTPRatingProfiles)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ var (
|
||||
CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheLoadIDs, CacheAccounts})
|
||||
|
||||
CacheStorDBPartitions = NewStringSet([]string{TBLTPTimings, TBLTPDestinations, TBLTPRates,
|
||||
TBLTPDestinationRates, TBLTPRatingPlans, TBLTPRateProfiles, TBLTPSharedGroups,
|
||||
TBLTPDestinationRates, TBLTPRatingPlans, TBLTPRatingProfiles, TBLTPSharedGroups,
|
||||
TBLTPActions, TBLTPActionPlans, TBLTPActionTriggers, TBLTPAccountActions, TBLTPResources, TBLTPStats,
|
||||
TBLTPThresholds, TBLTPFilters, SessionCostsTBL, CDRsTBL,
|
||||
TBLTPRoutes, TBLTPAttributes, TBLTPChargers, TBLTPDispatchers, TBLTPDispatcherHosts})
|
||||
@@ -1554,7 +1554,7 @@ const (
|
||||
TBLTPRates = "tp_rates"
|
||||
TBLTPDestinationRates = "tp_destination_rates"
|
||||
TBLTPRatingPlans = "tp_rating_plans"
|
||||
TBLTPRateProfiles = "tp_rating_profiles"
|
||||
TBLTPRatingProfiles = "tp_rating_profiles"
|
||||
TBLTPSharedGroups = "tp_shared_groups"
|
||||
TBLTPActions = "tp_actions"
|
||||
TBLTPActionPlans = "tp_action_plans"
|
||||
|
||||
Reference in New Issue
Block a user