|
|
|
|
@@ -32,14 +32,14 @@ func (iDB *InternalDB) GetTpIds(colName string) (ids []string, err error) {
|
|
|
|
|
tpIDs := utils.NewStringSet(nil)
|
|
|
|
|
if colName == "" { // if colName is empty we need to parse all partitions
|
|
|
|
|
for _, conNm := range utils.CacheStorDBPartitions.AsSlice() {
|
|
|
|
|
keys := iDB.db.GetItemIDs(conNm, utils.EmptyString)
|
|
|
|
|
keys := Cache.GetItemIDs(conNm, utils.EmptyString)
|
|
|
|
|
for _, key := range keys {
|
|
|
|
|
tpIDs.Add(strings.Split(key, utils.InInFieldSep)[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// iterate through all columns
|
|
|
|
|
} else {
|
|
|
|
|
keys := iDB.db.GetItemIDs(colName, utils.EmptyString)
|
|
|
|
|
keys := Cache.GetItemIDs(colName, utils.EmptyString)
|
|
|
|
|
for _, key := range keys {
|
|
|
|
|
tpIDs.Add(strings.Split(key, utils.InInFieldSep)[0])
|
|
|
|
|
}
|
|
|
|
|
@@ -49,7 +49,7 @@ func (iDB *InternalDB) GetTpIds(colName string) (ids []string, err error) {
|
|
|
|
|
|
|
|
|
|
func (iDB *InternalDB) GetTpTableIds(tpid, table string, distinct utils.TPDistinctIds,
|
|
|
|
|
filters map[string]string, paginator *utils.PaginatorWithSearch) (ids []string, err error) {
|
|
|
|
|
fullIDs := iDB.db.GetItemIDs(table, tpid)
|
|
|
|
|
fullIDs := Cache.GetItemIDs(table, tpid)
|
|
|
|
|
idSet := utils.NewStringSet(nil)
|
|
|
|
|
for _, fullID := range fullIDs {
|
|
|
|
|
switch table {
|
|
|
|
|
@@ -76,9 +76,9 @@ func (iDB *InternalDB) GetTPTimings(tpid, id string) (timings []*utils.ApierTPTi
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPTimings, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPTimings, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPTimings, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPTimings, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -95,9 +95,9 @@ func (iDB *InternalDB) GetTPDestinations(tpid, id string) (dsts []*utils.TPDesti
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPDestinations, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPDestinations, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPDestinations, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPDestinations, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -115,9 +115,9 @@ func (iDB *InternalDB) GetTPRates(tpid, id string) (rates []*utils.TPRateRALs, e
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPRates, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPRates, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPRates, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPRates, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -140,9 +140,9 @@ func (iDB *InternalDB) GetTPDestinationRates(tpid, id string,
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPDestinationRates, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPDestinationRates, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPDestinationRates, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPDestinationRates, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -185,9 +185,9 @@ func (iDB *InternalDB) GetTPRatingPlans(tpid, id string, paginator *utils.Pagina
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPRatingPlans, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPRatingPlans, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPRatingPlans, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPRatingPlans, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -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.TBLTPRatingProfiles, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPRatingProfiles, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPRatingProfiles, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPRatingProfiles, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -259,9 +259,9 @@ func (iDB *InternalDB) GetTPSharedGroups(tpid, id string) (sGroups []*utils.TPSh
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPSharedGroups, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPSharedGroups, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPSharedGroups, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPSharedGroups, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -279,9 +279,9 @@ func (iDB *InternalDB) GetTPActions(tpid, id string) (actions []*utils.TPActions
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPActions, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPActions, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPActions, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPActions, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -299,9 +299,9 @@ func (iDB *InternalDB) GetTPActionPlans(tpid, id string) (aPlans []*utils.TPActi
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPActionPlans, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPActionPlans, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPActionPlans, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPActionPlans, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -319,9 +319,9 @@ func (iDB *InternalDB) GetTPActionTriggers(tpid, id string) (aTriggers []*utils.
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPActionTriggers, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPActionTriggers, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPActionTriggers, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPActionTriggers, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -344,9 +344,9 @@ func (iDB *InternalDB) GetTPAccountActions(filter *utils.TPAccountActions) (acco
|
|
|
|
|
if filter.Account != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + filter.Account
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPAccountActions, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPAccountActions, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPAccountActions, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPAccountActions, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -367,9 +367,9 @@ func (iDB *InternalDB) GetTPResources(tpid, tenant, id string) (resources []*uti
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPResources, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPResources, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPResources, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPResources, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -390,9 +390,9 @@ func (iDB *InternalDB) GetTPStats(tpid, tenant, id string) (stats []*utils.TPSta
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPStats, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPStats, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPStats, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPStats, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -413,9 +413,9 @@ func (iDB *InternalDB) GetTPThresholds(tpid, tenant, id string) (ths []*utils.TP
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPThresholds, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPThresholds, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPThresholds, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPThresholds, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -436,9 +436,9 @@ func (iDB *InternalDB) GetTPFilters(tpid, tenant, id string) (fltrs []*utils.TPF
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPFilters, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPFilters, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPFilters, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPFilters, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -459,9 +459,9 @@ func (iDB *InternalDB) GetTPRoutes(tpid, tenant, id string) (supps []*utils.TPRo
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPRoutes, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPRoutes, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPRoutes, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPRoutes, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -482,9 +482,9 @@ func (iDB *InternalDB) GetTPAttributes(tpid, tenant, id string) (attrs []*utils.
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPAttributes, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPAttributes, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPAttributes, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPAttributes, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -505,9 +505,9 @@ func (iDB *InternalDB) GetTPChargers(tpid, tenant, id string) (cpps []*utils.TPC
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPChargers, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPChargers, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPChargers, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPChargers, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -528,9 +528,9 @@ func (iDB *InternalDB) GetTPDispatcherProfiles(tpid, tenant, id string) (dpps []
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPDispatchers, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPDispatchers, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPDispatchers, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPDispatchers, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -551,9 +551,9 @@ func (iDB *InternalDB) GetTPDispatcherHosts(tpid, tenant, id string) (dpps []*ut
|
|
|
|
|
if id != utils.EmptyString {
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + id
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(utils.TBLTPDispatcherHosts, key)
|
|
|
|
|
ids := Cache.GetItemIDs(utils.TBLTPDispatcherHosts, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
x, ok := iDB.db.Get(utils.TBLTPDispatcherHosts, id)
|
|
|
|
|
x, ok := Cache.Get(utils.TBLTPDispatcherHosts, id)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -599,9 +599,9 @@ func (iDB *InternalDB) RemTpData(table, tpid string, args map[string]string) (er
|
|
|
|
|
key += utils.CONCATENATED_KEY_SEP + val
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ids := iDB.db.GetItemIDs(table, key)
|
|
|
|
|
ids := Cache.GetItemIDs(table, key)
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
iDB.db.Remove(table, id,
|
|
|
|
|
Cache.Remove(table, id,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -612,7 +612,7 @@ func (iDB *InternalDB) SetTPTimings(timings []*utils.ApierTPTiming) (err error)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, timing := range timings {
|
|
|
|
|
iDB.db.Set(utils.TBLTPTimings, utils.ConcatenatedKey(timing.TPid, timing.ID), timing, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPTimings, utils.ConcatenatedKey(timing.TPid, timing.ID), timing, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -622,7 +622,7 @@ func (iDB *InternalDB) SetTPDestinations(dests []*utils.TPDestination) (err erro
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, destination := range dests {
|
|
|
|
|
iDB.db.Set(utils.TBLTPDestinations, utils.ConcatenatedKey(destination.TPid, destination.ID), destination, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPDestinations, utils.ConcatenatedKey(destination.TPid, destination.ID), destination, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -633,7 +633,7 @@ func (iDB *InternalDB) SetTPRates(rates []*utils.TPRateRALs) (err error) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, rate := range rates {
|
|
|
|
|
iDB.db.Set(utils.TBLTPRates, utils.ConcatenatedKey(rate.TPid, rate.ID), rate, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPRates, utils.ConcatenatedKey(rate.TPid, rate.ID), rate, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -644,7 +644,7 @@ func (iDB *InternalDB) SetTPDestinationRates(dRates []*utils.TPDestinationRate)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, dRate := range dRates {
|
|
|
|
|
iDB.db.Set(utils.TBLTPDestinationRates, utils.ConcatenatedKey(dRate.TPid, dRate.ID), dRate, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPDestinationRates, utils.ConcatenatedKey(dRate.TPid, dRate.ID), dRate, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -655,7 +655,7 @@ func (iDB *InternalDB) SetTPRatingPlans(ratingPlans []*utils.TPRatingPlan) (err
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, rPlan := range ratingPlans {
|
|
|
|
|
iDB.db.Set(utils.TBLTPRatingPlans, utils.ConcatenatedKey(rPlan.TPid, rPlan.ID), rPlan, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPRatingPlans, utils.ConcatenatedKey(rPlan.TPid, rPlan.ID), rPlan, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -666,7 +666,7 @@ func (iDB *InternalDB) SetTPRatingProfiles(ratingProfiles []*utils.TPRatingProfi
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, rProfile := range ratingProfiles {
|
|
|
|
|
iDB.db.Set(utils.TBLTPRatingProfiles, utils.ConcatenatedKey(rProfile.TPid,
|
|
|
|
|
Cache.Set(utils.TBLTPRatingProfiles, utils.ConcatenatedKey(rProfile.TPid,
|
|
|
|
|
rProfile.LoadId, rProfile.Tenant, rProfile.Category, rProfile.Subject), rProfile, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
@@ -678,7 +678,7 @@ func (iDB *InternalDB) SetTPSharedGroups(groups []*utils.TPSharedGroups) (err er
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, group := range groups {
|
|
|
|
|
iDB.db.Set(utils.TBLTPSharedGroups, utils.ConcatenatedKey(group.TPid, group.ID), group, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPSharedGroups, utils.ConcatenatedKey(group.TPid, group.ID), group, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -689,7 +689,7 @@ func (iDB *InternalDB) SetTPActions(acts []*utils.TPActions) (err error) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, action := range acts {
|
|
|
|
|
iDB.db.Set(utils.TBLTPActions, utils.ConcatenatedKey(action.TPid, action.ID), action, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPActions, utils.ConcatenatedKey(action.TPid, action.ID), action, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -700,7 +700,7 @@ func (iDB *InternalDB) SetTPActionPlans(aPlans []*utils.TPActionPlan) (err error
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, aPlan := range aPlans {
|
|
|
|
|
iDB.db.Set(utils.TBLTPActionPlans, utils.ConcatenatedKey(aPlan.TPid, aPlan.ID), aPlan, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPActionPlans, utils.ConcatenatedKey(aPlan.TPid, aPlan.ID), aPlan, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -711,7 +711,7 @@ func (iDB *InternalDB) SetTPActionTriggers(aTriggers []*utils.TPActionTriggers)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, aTrigger := range aTriggers {
|
|
|
|
|
iDB.db.Set(utils.TBLTPActionTriggers, utils.ConcatenatedKey(aTrigger.TPid, aTrigger.ID), aTrigger, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPActionTriggers, utils.ConcatenatedKey(aTrigger.TPid, aTrigger.ID), aTrigger, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -722,7 +722,7 @@ func (iDB *InternalDB) SetTPAccountActions(accActions []*utils.TPAccountActions)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, accAction := range accActions {
|
|
|
|
|
iDB.db.Set(utils.TBLTPAccountActions, utils.ConcatenatedKey(accAction.TPid,
|
|
|
|
|
Cache.Set(utils.TBLTPAccountActions, utils.ConcatenatedKey(accAction.TPid,
|
|
|
|
|
accAction.LoadId, accAction.Tenant, accAction.Account), accAction, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
@@ -734,7 +734,7 @@ func (iDB *InternalDB) SetTPResources(resources []*utils.TPResourceProfile) (err
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, resource := range resources {
|
|
|
|
|
iDB.db.Set(utils.TBLTPResources, utils.ConcatenatedKey(resource.TPid, resource.Tenant, resource.ID), resource, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPResources, utils.ConcatenatedKey(resource.TPid, resource.Tenant, resource.ID), resource, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -744,7 +744,7 @@ func (iDB *InternalDB) SetTPStats(stats []*utils.TPStatProfile) (err error) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, stat := range stats {
|
|
|
|
|
iDB.db.Set(utils.TBLTPStats, utils.ConcatenatedKey(stat.TPid, stat.Tenant, stat.ID), stat, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPStats, utils.ConcatenatedKey(stat.TPid, stat.Tenant, stat.ID), stat, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -755,7 +755,7 @@ func (iDB *InternalDB) SetTPThresholds(thresholds []*utils.TPThresholdProfile) (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, threshold := range thresholds {
|
|
|
|
|
iDB.db.Set(utils.TBLTPThresholds, utils.ConcatenatedKey(threshold.TPid, threshold.Tenant, threshold.ID), threshold, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPThresholds, utils.ConcatenatedKey(threshold.TPid, threshold.Tenant, threshold.ID), threshold, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -766,7 +766,7 @@ func (iDB *InternalDB) SetTPFilters(filters []*utils.TPFilterProfile) (err error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, filter := range filters {
|
|
|
|
|
iDB.db.Set(utils.TBLTPFilters, utils.ConcatenatedKey(filter.TPid, filter.Tenant, filter.ID), filter, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPFilters, utils.ConcatenatedKey(filter.TPid, filter.Tenant, filter.ID), filter, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -777,7 +777,7 @@ func (iDB *InternalDB) SetTPRoutes(routes []*utils.TPRouteProfile) (err error) {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, route := range routes {
|
|
|
|
|
iDB.db.Set(utils.TBLTPRoutes, utils.ConcatenatedKey(route.TPid, route.Tenant, route.ID), route, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPRoutes, utils.ConcatenatedKey(route.TPid, route.Tenant, route.ID), route, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -789,7 +789,7 @@ func (iDB *InternalDB) SetTPAttributes(attributes []*utils.TPAttributeProfile) (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, attribute := range attributes {
|
|
|
|
|
iDB.db.Set(utils.TBLTPAttributes, utils.ConcatenatedKey(attribute.TPid, attribute.Tenant, attribute.ID), attribute, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPAttributes, utils.ConcatenatedKey(attribute.TPid, attribute.Tenant, attribute.ID), attribute, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -800,7 +800,7 @@ func (iDB *InternalDB) SetTPChargers(cpps []*utils.TPChargerProfile) (err error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, cpp := range cpps {
|
|
|
|
|
iDB.db.Set(utils.TBLTPChargers, utils.ConcatenatedKey(cpp.TPid, cpp.Tenant, cpp.ID), cpp, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPChargers, utils.ConcatenatedKey(cpp.TPid, cpp.Tenant, cpp.ID), cpp, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -811,7 +811,7 @@ func (iDB *InternalDB) SetTPDispatcherProfiles(dpps []*utils.TPDispatcherProfile
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, dpp := range dpps {
|
|
|
|
|
iDB.db.Set(utils.TBLTPDispatchers, utils.ConcatenatedKey(dpp.TPid, dpp.Tenant, dpp.ID), dpp, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPDispatchers, utils.ConcatenatedKey(dpp.TPid, dpp.Tenant, dpp.ID), dpp, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -821,7 +821,7 @@ func (iDB *InternalDB) SetTPDispatcherHosts(dpps []*utils.TPDispatcherHost) (err
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
for _, dpp := range dpps {
|
|
|
|
|
iDB.db.Set(utils.TBLTPDispatcherHosts, utils.ConcatenatedKey(dpp.TPid, dpp.Tenant, dpp.ID), dpp, nil,
|
|
|
|
|
Cache.Set(utils.TBLTPDispatcherHosts, utils.ConcatenatedKey(dpp.TPid, dpp.Tenant, dpp.ID), dpp, nil,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
@@ -845,7 +845,7 @@ func (iDB *InternalDB) SetCDR(cdr *CDR, allowUpdate bool) (err error) {
|
|
|
|
|
}
|
|
|
|
|
cdrKey := utils.ConcatenatedKey(cdr.CGRID, cdr.RunID, cdr.OriginID)
|
|
|
|
|
if !allowUpdate {
|
|
|
|
|
if _, has := iDB.db.Get(utils.CDRsTBL, cdrKey); has {
|
|
|
|
|
if _, has := Cache.Get(utils.CDRsTBL, cdrKey); has {
|
|
|
|
|
return utils.ErrExists
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -882,14 +882,14 @@ func (iDB *InternalDB) SetCDR(cdr *CDR, allowUpdate bool) (err error) {
|
|
|
|
|
}
|
|
|
|
|
iDB.indexedFieldsMutex.RUnlock()
|
|
|
|
|
|
|
|
|
|
iDB.db.Set(utils.CDRsTBL, cdrKey, cdr, idxs.AsSlice(),
|
|
|
|
|
Cache.Set(utils.CDRsTBL, cdrKey, cdr, idxs.AsSlice(),
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (iDB *InternalDB) RemoveSMCost(smc *SMCost) (err error) {
|
|
|
|
|
iDB.db.Remove(utils.SessionCostsTBL, utils.ConcatenatedKey(smc.CGRID, smc.RunID, smc.OriginHost, smc.OriginID),
|
|
|
|
|
Cache.Remove(utils.SessionCostsTBL, utils.ConcatenatedKey(smc.CGRID, smc.RunID, smc.OriginHost, smc.OriginID),
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
@@ -912,7 +912,7 @@ func (iDB *InternalDB) RemoveSMCosts(qryFltr *utils.SMCostFilter) error {
|
|
|
|
|
}
|
|
|
|
|
grpMpIDs := make(utils.StringMap)
|
|
|
|
|
for _, id := range fltrSlc.ids {
|
|
|
|
|
grpIDs := iDB.db.GetGroupItemIDs(utils.SessionCostsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
grpIDs := Cache.tCache.GetGroupItemIDs(utils.SessionCostsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
for _, id := range grpIDs {
|
|
|
|
|
grpMpIDs[id] = true
|
|
|
|
|
}
|
|
|
|
|
@@ -935,7 +935,7 @@ func (iDB *InternalDB) RemoveSMCosts(qryFltr *utils.SMCostFilter) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if smMpIDs == nil {
|
|
|
|
|
smMpIDs = utils.StringMapFromSlice(iDB.db.GetItemIDs(utils.SessionCostsTBL, utils.EmptyString))
|
|
|
|
|
smMpIDs = utils.StringMapFromSlice(Cache.GetItemIDs(utils.SessionCostsTBL, utils.EmptyString))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check for Not filters
|
|
|
|
|
@@ -953,7 +953,7 @@ func (iDB *InternalDB) RemoveSMCosts(qryFltr *utils.SMCostFilter) error {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for _, id := range fltrSlc.ids {
|
|
|
|
|
grpIDs := iDB.db.GetGroupItemIDs(utils.CDRsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
grpIDs := Cache.tCache.GetGroupItemIDs(utils.CDRsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
for _, id := range grpIDs {
|
|
|
|
|
if smMpIDs.HasKey(id) {
|
|
|
|
|
delete(smMpIDs, id)
|
|
|
|
|
@@ -970,7 +970,7 @@ func (iDB *InternalDB) RemoveSMCosts(qryFltr *utils.SMCostFilter) error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for key := range smMpIDs {
|
|
|
|
|
iDB.db.Remove(utils.SessionCostsTBL, key,
|
|
|
|
|
Cache.Remove(utils.SessionCostsTBL, key,
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
@@ -1137,7 +1137,7 @@ func (iDB *InternalDB) GetCDRs(filter *utils.CDRsFilter, remove bool) (cdrs []*C
|
|
|
|
|
}
|
|
|
|
|
grpMpIDs := utils.NewStringSet([]string{})
|
|
|
|
|
for _, id := range fltrSlc.ids {
|
|
|
|
|
grpIDs := iDB.db.GetGroupItemIDs(utils.CDRsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
grpIDs := Cache.tCache.GetGroupItemIDs(utils.CDRsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
grpMpIDs.AddSlice(grpIDs)
|
|
|
|
|
}
|
|
|
|
|
if grpMpIDs.Size() == 0 {
|
|
|
|
|
@@ -1159,7 +1159,7 @@ func (iDB *InternalDB) GetCDRs(filter *utils.CDRsFilter, remove bool) (cdrs []*C
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if cdrMpIDs == nil {
|
|
|
|
|
cdrMpIDs = utils.NewStringSet(iDB.db.GetItemIDs(utils.CDRsTBL, utils.EmptyString))
|
|
|
|
|
cdrMpIDs = utils.NewStringSet(Cache.GetItemIDs(utils.CDRsTBL, utils.EmptyString))
|
|
|
|
|
}
|
|
|
|
|
// check for Not filters
|
|
|
|
|
for _, fltrSlc := range notPairSlice {
|
|
|
|
|
@@ -1167,7 +1167,7 @@ func (iDB *InternalDB) GetCDRs(filter *utils.CDRsFilter, remove bool) (cdrs []*C
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for _, id := range fltrSlc.ids {
|
|
|
|
|
grpIDs := iDB.db.GetGroupItemIDs(utils.CDRsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
grpIDs := Cache.tCache.GetGroupItemIDs(utils.CDRsTBL, utils.ConcatenatedKey(fltrSlc.key, id))
|
|
|
|
|
for _, id := range grpIDs {
|
|
|
|
|
if cdrMpIDs.Has(id) {
|
|
|
|
|
cdrMpIDs.Remove(id)
|
|
|
|
|
@@ -1207,7 +1207,7 @@ func (iDB *InternalDB) GetCDRs(filter *utils.CDRsFilter, remove bool) (cdrs []*C
|
|
|
|
|
|
|
|
|
|
paginatorOffsetCounter := 0
|
|
|
|
|
for key := range cdrMpIDs {
|
|
|
|
|
x, ok := iDB.db.Get(utils.CDRsTBL, key)
|
|
|
|
|
x, ok := Cache.Get(utils.CDRsTBL, key)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, 0, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -1653,7 +1653,7 @@ func (iDB *InternalDB) GetCDRs(filter *utils.CDRsFilter, remove bool) (cdrs []*C
|
|
|
|
|
}
|
|
|
|
|
if remove {
|
|
|
|
|
for _, cdr := range cdrs {
|
|
|
|
|
iDB.db.Remove(utils.CDRsTBL, utils.ConcatenatedKey(cdr.CGRID, cdr.RunID, cdr.OriginID),
|
|
|
|
|
Cache.Remove(utils.CDRsTBL, utils.ConcatenatedKey(cdr.CGRID, cdr.RunID, cdr.OriginID),
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
}
|
|
|
|
|
return nil, 0, nil
|
|
|
|
|
@@ -1742,7 +1742,7 @@ func (iDB *InternalDB) GetSMCosts(cgrid, runid, originHost, originIDPrfx string)
|
|
|
|
|
}
|
|
|
|
|
grpMpIDs := make(utils.StringMap)
|
|
|
|
|
|
|
|
|
|
grpIDs := iDB.db.GetGroupItemIDs(utils.SessionCostsTBL, utils.ConcatenatedKey(fltrSlc.key, fltrSlc.id))
|
|
|
|
|
grpIDs := Cache.tCache.GetGroupItemIDs(utils.SessionCostsTBL, utils.ConcatenatedKey(fltrSlc.key, fltrSlc.id))
|
|
|
|
|
for _, id := range grpIDs {
|
|
|
|
|
grpMpIDs[id] = true
|
|
|
|
|
}
|
|
|
|
|
@@ -1764,13 +1764,13 @@ func (iDB *InternalDB) GetSMCosts(cgrid, runid, originHost, originIDPrfx string)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if smMpIDs == nil {
|
|
|
|
|
smMpIDs = utils.StringMapFromSlice(iDB.db.GetItemIDs(utils.SessionCostsTBL, utils.EmptyString))
|
|
|
|
|
smMpIDs = utils.StringMapFromSlice(Cache.GetItemIDs(utils.SessionCostsTBL, utils.EmptyString))
|
|
|
|
|
}
|
|
|
|
|
if len(smMpIDs) == 0 {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
for key := range smMpIDs {
|
|
|
|
|
x, ok := iDB.db.Get(utils.SessionCostsTBL, key)
|
|
|
|
|
x, ok := Cache.Get(utils.SessionCostsTBL, key)
|
|
|
|
|
if !ok || x == nil {
|
|
|
|
|
return nil, utils.ErrNotFound
|
|
|
|
|
}
|
|
|
|
|
@@ -1793,7 +1793,7 @@ func (iDB *InternalDB) SetSMCost(smCost *SMCost) (err error) {
|
|
|
|
|
idxs.Add(utils.ConcatenatedKey(utils.OriginHost, smCost.OriginHost))
|
|
|
|
|
idxs.Add(utils.ConcatenatedKey(utils.OriginID, smCost.OriginID))
|
|
|
|
|
idxs.Add(utils.ConcatenatedKey(utils.CostSource, smCost.CostSource))
|
|
|
|
|
iDB.db.Set(utils.SessionCostsTBL, utils.ConcatenatedKey(smCost.CGRID, smCost.RunID, smCost.OriginHost, smCost.OriginID), smCost, idxs.AsSlice(),
|
|
|
|
|
Cache.Set(utils.SessionCostsTBL, utils.ConcatenatedKey(smCost.CGRID, smCost.RunID, smCost.OriginHost, smCost.OriginID), smCost, idxs.AsSlice(),
|
|
|
|
|
cacheCommit(utils.NonTransactional), utils.NonTransactional)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|