mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added copunt/list rates for internal driver
This commit is contained in:
committed by
Dan Christian Bogos
parent
d7e5ff23ac
commit
2bcd034c02
@@ -27,7 +27,7 @@ type DataDBMock struct {
|
||||
RemoveRateProfileDrvF func(ctx *context.Context, str1 string, str2 string, rateIDs *[]string) error
|
||||
SetRateProfileDrvF func(*context.Context, *utils.RateProfile) error
|
||||
GetRateProfileDrvF func(*context.Context, string, string) (*utils.RateProfile, error)
|
||||
GetRateProfileRateidSDrvF func(*context.Context, string, string) ([]string, error)
|
||||
GetRateProfileRateidSDrvF func(*context.Context, string, string, string) ([]string, error)
|
||||
GetKeysForPrefixF func(*context.Context, string) ([]string, error)
|
||||
GetIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx, idxKey, transactionID string) (indexes map[string]utils.StringSet, err error)
|
||||
SetIndexesDrvF func(ctx *context.Context, idxItmType, tntCtx string, indexes map[string]utils.StringSet, commit bool, transactionID string) (err error)
|
||||
@@ -376,9 +376,9 @@ func (dbM *DataDBMock) GetRateProfileDrv(ctx *context.Context, tnt string, id st
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (dbM *DataDBMock) GetRateProfileRateIDsDrv(ctx *context.Context, tnt string, id string) ([]string, error) {
|
||||
func (dbM *DataDBMock) GetRateProfileRateIDsDrv(ctx *context.Context, tnt string, id string, prefixArgs string) ([]string, error) {
|
||||
if dbM.GetRateProfileRateidSDrvF != nil {
|
||||
return dbM.GetRateProfileRateIDsDrv(ctx, tnt, id)
|
||||
return dbM.GetRateProfileRateIDsDrv(ctx, tnt, id, prefixArgs)
|
||||
}
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
@@ -1944,12 +1944,10 @@ func (dm *DataManager) GetRateProfile(ctx *context.Context, tenant, id string, c
|
||||
}
|
||||
|
||||
func (dm *DataManager) GetRateProfileRateIDs(ctx *context.Context, args *utils.ArgsSubItemIDs) (rateIDs []string, err error) {
|
||||
key := utils.RateProfilePrefix + utils.ConcatenatedKey(args.Tenant, args.ProfileID)
|
||||
prefix := utils.Rates + utils.ConcatenatedKeySep
|
||||
if args.ItemsPrefix != utils.EmptyString {
|
||||
prefix = utils.ConcatenatedKey(utils.Rates, args.ItemsPrefix)
|
||||
if dm == nil {
|
||||
return nil, utils.ErrNoDatabaseConn
|
||||
}
|
||||
return dm.DataDB().GetRateProfileRateIDsDrv(ctx, key, prefix)
|
||||
return dm.DataDB().GetRateProfileRateIDsDrv(ctx, args.Tenant, args.ProfileID, args.ItemsPrefix)
|
||||
}
|
||||
|
||||
func (dm *DataManager) SetRateProfile(ctx *context.Context, rpp *utils.RateProfile, withIndex bool) (err error) {
|
||||
|
||||
@@ -86,7 +86,7 @@ type DataDB interface {
|
||||
SetDispatcherHostDrv(*context.Context, *DispatcherHost) error
|
||||
RemoveDispatcherHostDrv(*context.Context, string, string) error
|
||||
GetRateProfileDrv(*context.Context, string, string) (*utils.RateProfile, error)
|
||||
GetRateProfileRateIDsDrv(*context.Context, string, string) ([]string, error)
|
||||
GetRateProfileRateIDsDrv(*context.Context, string, string, string) ([]string, error)
|
||||
SetRateProfileDrv(*context.Context, *utils.RateProfile) error
|
||||
RemoveRateProfileDrv(*context.Context, string, string, *[]string) error
|
||||
GetActionProfileDrv(*context.Context, string, string) (*ActionProfile, error)
|
||||
|
||||
@@ -476,7 +476,16 @@ func (iDB *InternalDB) GetRateProfileDrv(_ *context.Context, tenant, id string)
|
||||
return x.(*utils.RateProfile), nil
|
||||
}
|
||||
|
||||
func (iDB *InternalDB) GetRateProfileRateIDsDrv(ctx *context.Context, key, prefix string) (rateIDs []string, err error) {
|
||||
func (iDB *InternalDB) GetRateProfileRateIDsDrv(ctx *context.Context, tenant, profileID, prefixArgs string) (rateIDs []string, err error) {
|
||||
x, ok := iDB.db.Get(utils.CacheRateProfiles, utils.ConcatenatedKey(tenant, profileID))
|
||||
if !ok || x == nil {
|
||||
return nil, utils.ErrNotFound
|
||||
}
|
||||
for key := range x.(*utils.RateProfile).Rates {
|
||||
if strings.HasPrefix(key, prefixArgs) {
|
||||
rateIDs = append(rateIDs, key)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1221,7 +1221,7 @@ func (ms *MongoStorage) GetRateProfileDrv(ctx *context.Context, tenant, id strin
|
||||
return utils.NewRateProfileFromMapDataDBMap(tenant, id, mapRP, ms.ms)
|
||||
}
|
||||
|
||||
func (ms *MongoStorage) GetRateProfileRateIDsDrv(ctx *context.Context, key, prefix string) (rateIDs []string, err error) {
|
||||
func (ms *MongoStorage) GetRateProfileRateIDsDrv(ctx *context.Context, key, prefix, argsPrefix string) (rateIDs []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -748,7 +748,12 @@ func (rs *RedisStorage) GetRateProfileDrv(ctx *context.Context, tenant, id strin
|
||||
return utils.NewRateProfileFromMapDataDBMap(tenant, id, mapRP, rs.ms)
|
||||
}
|
||||
|
||||
func (rs *RedisStorage) GetRateProfileRateIDsDrv(ctx *context.Context, key, prefix string) (rateIDs []string, err error) {
|
||||
func (rs *RedisStorage) GetRateProfileRateIDsDrv(ctx *context.Context, tnt, profileID, prefixArgs string) (rateIDs []string, err error) {
|
||||
key := utils.RateProfilePrefix + utils.ConcatenatedKey(tnt, profileID)
|
||||
prefix := utils.Rates + utils.ConcatenatedKeySep
|
||||
if prefixArgs != utils.EmptyString {
|
||||
prefix = utils.ConcatenatedKey(utils.Rates, prefixArgs)
|
||||
}
|
||||
var rateField string
|
||||
scan := radix.NewScanner(rs.client, radix.ScanOpts{
|
||||
Command: redisHSCAN,
|
||||
|
||||
Reference in New Issue
Block a user