Fix merge problems

This commit is contained in:
TeoV
2019-03-27 12:11:51 +02:00
committed by Dan Christian Bogos
parent 827503ce60
commit f3c137f195
2 changed files with 37 additions and 2 deletions

View File

@@ -92,9 +92,9 @@ func testTPActionTriggersInitCfg(t *testing.T) {
config.SetCgrConfig(tpActionTriggerCfg)
switch tpActionTriggerConfigDIR {
case "tutmongo": // Mongo needs more time to reset db, need to investigate
tpActionDelay = 2000
tpActionTriggerDelay = 2000
default:
tpActionDelay = 1000
tpActionTriggerDelay = 1000
}
}

View File

@@ -72,6 +72,7 @@ const (
colCpp = "charger_profiles"
colDpp = "dispatcher_profiles"
colDph = "dispatcher_hosts"
colLID = "load_ids"
)
var (
@@ -2189,3 +2190,37 @@ func (ms *MongoStorage) RemoveDispatcherHostDrv(tenant, id string) (err error) {
return err
})
}
func (ms *MongoStorage) GetItemLoadIDsDrv(itemIDPrefix string) (loadIDs map[string]string, err error) {
fop := options.FindOne()
if itemIDPrefix != "" {
fop.SetProjection(bson.M{itemIDPrefix: 1, "_id": 0})
} else {
fop.SetProjection(bson.M{"_id": 0})
}
if err = ms.query(func(sctx mongo.SessionContext) (err error) {
cur := ms.getCol(colLID).FindOne(sctx, bson.D{}, fop)
if err := cur.Decode(&loadIDs); err != nil {
if err == mongo.ErrNoDocuments {
return utils.ErrNotFound
}
return err
}
return nil
}); err != nil {
return nil, err
}
if len(loadIDs) == 0 {
return nil, utils.ErrNotFound
}
return
}
func (ms *MongoStorage) SetLoadIDsDrv(loadIDs map[string]string) (err error) {
return ms.query(func(sctx mongo.SessionContext) (err error) {
_, err = ms.getCol(colLID).UpdateOne(sctx, bson.D{}, bson.M{"$set": loadIDs},
options.Update().SetUpsert(true),
)
return err
})
}