mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 07:38:45 +05:00
Updated internal and mongo db code for removing cases
This commit is contained in:
committed by
Dan Christian Bogos
parent
14f5915b36
commit
166670b0d7
@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
|
||||
package engine
|
||||
|
||||
import (
|
||||
@@ -55,8 +54,8 @@ func TestCDRSV1ProcessCDRNoTenant(t *testing.T) {
|
||||
*rply = AttrSProcessEventReply{
|
||||
AlteredFields: []string{utils.Account},
|
||||
CGREvent: &utils.CGREvent{
|
||||
ID: "TestBiRPCv1AuthorizeEventNoTenant",
|
||||
Time: utils.TimePointer(time.Date(2016, time.January, 5, 18, 30, 49, 0, time.UTC)),
|
||||
ID: "TestBiRPCv1AuthorizeEventNoTenant",
|
||||
Time: utils.TimePointer(time.Date(2016, time.January, 5, 18, 30, 49, 0, time.UTC)),
|
||||
Event: map[string]interface{}{
|
||||
"Account": "1002",
|
||||
"Category": "call",
|
||||
@@ -78,10 +77,10 @@ func TestCDRSV1ProcessCDRNoTenant(t *testing.T) {
|
||||
db := NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items)
|
||||
dm := NewDataManager(db, cfg.CacheCfg(), connMngr)
|
||||
cdrs := &CDRServer{
|
||||
cgrCfg: cfg,
|
||||
cgrCfg: cfg,
|
||||
connMgr: connMngr,
|
||||
cdrDb: NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items),
|
||||
dm: dm,
|
||||
cdrDb: NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items),
|
||||
dm: dm,
|
||||
}
|
||||
cdr := &CDRWithArgDispatcher{ // no tenant, take the default
|
||||
CDR: &CDR{
|
||||
@@ -137,10 +136,10 @@ func TestCDRSV1ProcessEventNoTenant(t *testing.T) {
|
||||
db := NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items)
|
||||
dm := NewDataManager(db, cfg.CacheCfg(), connMngr)
|
||||
cdrs := &CDRServer{
|
||||
cgrCfg: cfg,
|
||||
cgrCfg: cfg,
|
||||
connMgr: connMngr,
|
||||
cdrDb: NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items),
|
||||
dm: dm,
|
||||
cdrDb: NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items),
|
||||
dm: dm,
|
||||
}
|
||||
args := &ArgV1ProcessEvent{
|
||||
Flags: []string{utils.MetaChargers},
|
||||
@@ -194,10 +193,10 @@ func TestCDRSV1V1ProcessExternalCDRNoTenant(t *testing.T) {
|
||||
db := NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items)
|
||||
dm := NewDataManager(db, cfg.CacheCfg(), connMngr)
|
||||
cdrs := &CDRServer{
|
||||
cgrCfg: cfg,
|
||||
cgrCfg: cfg,
|
||||
connMgr: connMngr,
|
||||
cdrDb: NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items),
|
||||
dm: dm,
|
||||
cdrDb: NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items),
|
||||
dm: dm,
|
||||
}
|
||||
|
||||
args := &ExternalCDRWithArgDispatcher{
|
||||
@@ -224,4 +223,3 @@ func TestCDRSV1V1ProcessExternalCDRNoTenant(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,4 +143,3 @@ func testDMitCRUDStatQueue(t *testing.T) {
|
||||
t.Error(rcvErr)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -981,7 +981,7 @@ func (iDB *InternalDB) SetFilterIndexesDrv(cacheID, tntCtx string,
|
||||
dbKey = "tmp_" + utils.ConcatenatedKey(dbKey, transactionID)
|
||||
}
|
||||
if len(indx) == 0 {
|
||||
iDB.db.Set(cacheID, dbKey, nil, []string{tntCtx},
|
||||
iDB.db.Remove(cacheID, dbKey,
|
||||
true, utils.NonTransactional)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1686,15 +1686,25 @@ func (ms *MongoStorage) SetFilterIndexesDrv(cacheID, itemIDPrefix string,
|
||||
var lastErr error
|
||||
for key, itmMp := range indexes {
|
||||
if err = ms.query(func(sctx mongo.SessionContext) (err error) {
|
||||
var action bson.M
|
||||
// var action bson.M
|
||||
if len(itmMp) == 0 {
|
||||
action = bson.M{"$unset": bson.M{"value": 1}}
|
||||
_, err = ms.getCol(ColRFI).DeleteOne(sctx,
|
||||
bson.M{"key": utils.ConcatenatedKey(dbKey, key)})
|
||||
//action = bson.M{"$unset": bson.M{"value": 1}}
|
||||
} else {
|
||||
_, err = ms.getCol(ColRFI).UpdateOne(sctx, bson.M{"key": utils.ConcatenatedKey(dbKey, key)},
|
||||
bson.M{"$set": bson.M{"key": utils.ConcatenatedKey(dbKey, key), "value": itmMp.Slice()}},
|
||||
options.Update().SetUpsert(true),
|
||||
)
|
||||
}
|
||||
/*
|
||||
action = bson.M{"$set": bson.M{"key": utils.ConcatenatedKey(dbKey, key), "value": itmMp.Slice()}}
|
||||
}
|
||||
_, err = ms.getCol(ColRFI).UpdateOne(sctx, bson.M{"key": utils.ConcatenatedKey(dbKey, key)},
|
||||
action, options.Update().SetUpsert(true),
|
||||
)
|
||||
|
||||
*/
|
||||
return err
|
||||
}); err != nil {
|
||||
lastErr = err
|
||||
|
||||
Reference in New Issue
Block a user