mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
Add RemoveStatQueueProfile in Datamanger
This commit is contained in:
committed by
Dan Christian Bogos
parent
e4ae3e0a28
commit
761dd4fb32
@@ -57,7 +57,7 @@ func (apierV1 *ApierV1) RemStatQueueProfile(args *utils.TenantID, reply *string)
|
||||
if missing := utils.MissingStructFields(args, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
|
||||
return utils.NewErrMandatoryIeMissing(missing...)
|
||||
}
|
||||
if err := apierV1.DataManager.DataDB().RemStatQueueProfile(args.Tenant, args.ID, utils.NonTransactional); err != nil {
|
||||
if err := apierV1.DataManager.RemoveStatQueueProfile(args.Tenant, args.ID, utils.NonTransactional); err != nil {
|
||||
return utils.APIErrorHandler(err)
|
||||
}
|
||||
*reply = utils.OK
|
||||
|
||||
@@ -205,3 +205,12 @@ func (dm *DataManager) GetStatQueueProfile(tenant, id string, skipCache bool, tr
|
||||
func (dm *DataManager) SetStatQueueProfile(sqp *StatQueueProfile) (err error) {
|
||||
return dm.DataDB().SetStatQueueProfileDrv(sqp)
|
||||
}
|
||||
|
||||
func (dm *DataManager) RemoveStatQueueProfile(tenant, id, transactionID string) (err error) {
|
||||
if err = dm.DataDB().RemStatQueueProfileDrv(tenant, id); err != nil {
|
||||
return
|
||||
}
|
||||
cache.RemKey(utils.StatQueueProfilePrefix+utils.ConcatenatedKey(tenant, id),
|
||||
cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1994,7 +1994,7 @@ func testOnStorITCRUDStatQueueProfile(t *testing.T) {
|
||||
if _, ok := cache.Get(utils.StatQueueProfilePrefix + sq.ID); ok != false {
|
||||
t.Error("Should not be in cache")
|
||||
}
|
||||
if err := onStor.DataDB().RemStatQueueProfile(sq.Tenant, sq.ID, utils.NonTransactional); err != nil {
|
||||
if err := onStor.RemoveStatQueueProfile(sq.Tenant, sq.ID, utils.NonTransactional); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if _, ok := cache.Get(utils.StatQueueProfilePrefix + sq.ID); ok != false {
|
||||
|
||||
@@ -116,7 +116,7 @@ type DataDB interface {
|
||||
MatchReqFilterIndex(dbKey, fieldName, fieldVal string) (itemIDs utils.StringMap, err error)
|
||||
GetStatQueueProfileDrv(tenant string, ID string) (sq *StatQueueProfile, err error)
|
||||
SetStatQueueProfileDrv(sq *StatQueueProfile) (err error)
|
||||
RemStatQueueProfile(tenant, id, transactionID string) (err error)
|
||||
RemStatQueueProfileDrv(tenant, id string) (err error)
|
||||
GetStoredStatQueue(tenant, id string) (sq *StoredStatQueue, err error)
|
||||
SetStoredStatQueue(sq *StoredStatQueue) (err error)
|
||||
RemStoredStatQueue(tenant, id string) (err error)
|
||||
|
||||
@@ -1516,13 +1516,12 @@ func (ms *MapStorage) SetStatQueueProfileDrv(sqp *StatQueueProfile) (err error)
|
||||
return
|
||||
}
|
||||
|
||||
// RemStatsQueue removes a StatsQueue from dataDB
|
||||
func (ms *MapStorage) RemStatQueueProfile(tenant, id, transactionID string) (err error) {
|
||||
// RemStatsQueueDrv removes a StatsQueue from dataDB
|
||||
func (ms *MapStorage) RemStatQueueProfileDrv(tenant, id string) (err error) {
|
||||
ms.mu.Lock()
|
||||
defer ms.mu.Unlock()
|
||||
key := utils.StatQueueProfilePrefix + utils.ConcatenatedKey(tenant, id)
|
||||
delete(ms.dict, key)
|
||||
cache.RemKey(key, cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2100,16 +2100,14 @@ func (ms *MongoStorage) SetStatQueueProfileDrv(sq *StatQueueProfile) (err error)
|
||||
return
|
||||
}
|
||||
|
||||
// RemStatsQueue removes a StatsQueue from dataDB
|
||||
func (ms *MongoStorage) RemStatQueueProfile(tenant, id string, transactionID string) (err error) {
|
||||
// RemStatsQueueDrv removes a StatsQueue from dataDB
|
||||
func (ms *MongoStorage) RemStatQueueProfileDrv(tenant, id string) (err error) {
|
||||
session, col := ms.conn(colSqp)
|
||||
err = col.Remove(bson.M{"tenant": tenant, "id": id})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
session.Close()
|
||||
cache.RemKey(utils.StatQueueProfilePrefix+utils.ConcatenatedKey(tenant, id),
|
||||
cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1630,11 +1630,10 @@ func (rs *RedisStorage) SetStatQueueProfileDrv(sq *StatQueueProfile) (err error)
|
||||
return rs.Cmd("SET", utils.StatQueueProfilePrefix+utils.ConcatenatedKey(sq.Tenant, sq.ID), result).Err
|
||||
}
|
||||
|
||||
// RemStatsQueue removes a StatsQueue from dataDB
|
||||
func (rs *RedisStorage) RemStatQueueProfile(tenant, id string, transactionID string) (err error) {
|
||||
// RemStatsQueueDrv removes a StatsQueue from dataDB
|
||||
func (rs *RedisStorage) RemStatQueueProfileDrv(tenant, id string) (err error) {
|
||||
key := utils.StatQueueProfilePrefix + utils.ConcatenatedKey(tenant, id)
|
||||
err = rs.Cmd("DEL", key).Err
|
||||
cache.RemKey(key, cacheCommit(transactionID), transactionID)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user