Continue removing destinations

This commit is contained in:
andronache
2021-05-13 16:39:35 +03:00
committed by Dan Christian Bogos
parent bbb748dc54
commit 0579fc2b52
56 changed files with 49 additions and 669 deletions

View File

@@ -276,28 +276,6 @@ func (sqls *SQLStorage) SetTPTimings(timings []*utils.ApierTPTiming) error {
return nil
}
func (sqls *SQLStorage) SetTPDestinations(dests []*utils.TPDestination) error {
if len(dests) == 0 {
return nil
}
tx := sqls.db.Begin()
for _, dst := range dests {
// Remove previous
if err := tx.Where(&DestinationMdl{Tpid: dst.TPid, Tag: dst.ID}).Delete(DestinationMdl{}).Error; err != nil {
tx.Rollback()
return err
}
for _, d := range APItoModelDestination(dst) {
if err := tx.Create(&d).Error; err != nil {
tx.Rollback()
return err
}
}
}
tx.Commit()
return nil
}
func (sqls *SQLStorage) SetTPResources(rls []*utils.TPResourceProfile) error {
if len(rls) == 0 {
return nil
@@ -856,21 +834,6 @@ func (sqls *SQLStorage) GetCDRs(qryFltr *utils.CDRsFilter, remove bool) ([]*CDR,
return cdrs, 0, nil
}
func (sqls *SQLStorage) GetTPDestinations(tpid, id string) (uTPDsts []*utils.TPDestination, err error) {
var tpDests DestinationMdls
q := sqls.db.Where("tpid = ?", tpid)
if len(id) != 0 {
q = q.Where("tag = ?", id)
}
if err := q.Find(&tpDests).Error; err != nil {
return nil, err
}
if len(tpDests.AsTPDestinations()) == 0 {
return tpDests.AsTPDestinations(), utils.ErrNotFound
}
return tpDests.AsTPDestinations(), nil
}
func (sqls *SQLStorage) GetTPTimings(tpid, id string) ([]*utils.ApierTPTiming, error) {
var tpTimings TimingMdls
q := sqls.db.Where("tpid = ?", tpid)