mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated TP APIs
This commit is contained in:
committed by
Dan Christian Bogos
parent
72dbb523d0
commit
8e5ea6884e
@@ -42,20 +42,19 @@ func (m *Migrator) migrateCurrentTPChargers() (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if chargers != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPChargers(chargers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, charger := range chargers {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPChargers, charger.TPid,
|
||||
map[string]string{"id": charger.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpChargers] += 1
|
||||
if chargers == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPChargers(chargers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, charger := range chargers {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPChargers, charger.TPid,
|
||||
map[string]string{"id": charger.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpChargers] ++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -42,20 +42,19 @@ func (m *Migrator) migrateCurrentTPDispatchers() (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if dispatchers != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPDispatcherProfiles(dispatchers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, dispatcher := range dispatchers {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPDispatchers, dispatcher.TPid,
|
||||
map[string]string{"id": dispatcher.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpDispatchers] += 1
|
||||
if dispatchers == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPDispatcherProfiles(dispatchers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, dispatcher := range dispatchers {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPDispatchers, dispatcher.TPid,
|
||||
map[string]string{"id": dispatcher.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpDispatchers]++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -41,20 +41,19 @@ func (m *Migrator) migrateCurrentTPfilters() (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if fltrs != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPFilters(fltrs); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, fltr := range fltrs {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPFilters,
|
||||
fltr.TPid, map[string]string{"tenant": fltr.Tenant, "id": fltr.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpFilters] += 1
|
||||
if fltrs == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPFilters(fltrs); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, fltr := range fltrs {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPFilters,
|
||||
fltr.TPid, map[string]string{"tenant": fltr.Tenant, "id": fltr.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpFilters]++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -43,20 +43,19 @@ func (m *Migrator) migrateCurrentTPresources() (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resources != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPResources(resources); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, resource := range resources {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPResources, resource.TPid,
|
||||
map[string]string{"id": resource.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpResources] += 1
|
||||
if resources == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPResources(resources); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, resource := range resources {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPResources, resource.TPid,
|
||||
map[string]string{"id": resource.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpResources]++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -38,25 +38,23 @@ func (m *Migrator) migrateCurrentTPstats() (err error) {
|
||||
return err
|
||||
}
|
||||
for _, id := range ids {
|
||||
|
||||
stats, err := m.storDBIn.StorDB().GetTPStats(tpid, "", id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if stats != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPStats(stats); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, stat := range stats {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPStats, stat.TPid,
|
||||
map[string]string{"id": stat.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpStats] += 1
|
||||
if stats == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPStats(stats); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, stat := range stats {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPStats, stat.TPid,
|
||||
map[string]string{"id": stat.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpStats]++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -38,26 +38,24 @@ func (m *Migrator) migrateCurrentTPSuppliers() (err error) {
|
||||
return err
|
||||
}
|
||||
for _, id := range ids {
|
||||
|
||||
suppliers, err := m.storDBIn.StorDB().GetTPSuppliers(tpid, "", id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if suppliers != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPSuppliers(suppliers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, supplier := range suppliers {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPSuppliers, supplier.TPid,
|
||||
map[string]string{"tenant": supplier.Tenant, "id": supplier.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
m.stats[utils.TpSuppliers] += 1
|
||||
if suppliers == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPSuppliers(suppliers); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, supplier := range suppliers {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPSuppliers, supplier.TPid,
|
||||
map[string]string{"tenant": supplier.Tenant, "id": supplier.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
m.stats[utils.TpSuppliers]++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
@@ -38,25 +38,23 @@ func (m *Migrator) migrateCurrentTPthresholds() (err error) {
|
||||
return err
|
||||
}
|
||||
for _, id := range ids {
|
||||
|
||||
thresholds, err := m.storDBIn.StorDB().GetTPThresholds(tpid, "", id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if thresholds != nil {
|
||||
if m.dryRun != true {
|
||||
if err := m.storDBOut.StorDB().SetTPThresholds(thresholds); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, threshold := range thresholds {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPThresholds, threshold.TPid,
|
||||
map[string]string{"tenant": threshold.Tenant, "id": threshold.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpThresholds] += 1
|
||||
if thresholds == nil || m.dryRun {
|
||||
continue
|
||||
}
|
||||
if err := m.storDBOut.StorDB().SetTPThresholds(thresholds); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, threshold := range thresholds {
|
||||
if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPThresholds, threshold.TPid,
|
||||
map[string]string{"tenant": threshold.Tenant, "id": threshold.ID}); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
m.stats[utils.TpThresholds]++
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user