mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 22:29:55 +05:00
Updated cgr-migrator params and refactored GetTpIds
This commit is contained in:
committed by
Dan Christian Bogos
parent
3c9973c862
commit
261d160ee7
@@ -52,22 +52,21 @@ var (
|
||||
outStorDBUser = flag.String("out_stordb_user", config.CgrConfig().StorDBUser, "The storDb user to sign in as.")
|
||||
outStorDBPass = flag.String("out_stordb_passwd", config.CgrConfig().StorDBPass, "The storDb user's password.")
|
||||
|
||||
inDataDBType = flag.String("in_datadb_type", "", "The type of the DataDb Database <redis>")
|
||||
inDataDBHost = flag.String("in_datadb_host", config.CgrConfig().DataDbHost, "The DataDb host to connect to.")
|
||||
inDataDBPort = flag.String("in_datadb_port", config.CgrConfig().DataDbPort, "The DataDb port to bind to.")
|
||||
inDataDBName = flag.String("in_datadb_name", config.CgrConfig().DataDbName, "The name/number of the DataDb to connect to.")
|
||||
inDataDBUser = flag.String("in_datadb_user", config.CgrConfig().DataDbUser, "The DataDb user to sign in as.")
|
||||
inDataDBPass = flag.String("in_datadb_passwd", config.CgrConfig().DataDbPass, "The DataDb user's password.")
|
||||
inDataDBType = flag.String("datadb_type", "", "The type of the DataDb Database <redis>")
|
||||
inDataDBHost = flag.String("datadb_host", config.CgrConfig().DataDbHost, "The DataDb host to connect to.")
|
||||
inDataDBPort = flag.String("datadb_port", config.CgrConfig().DataDbPort, "The DataDb port to bind to.")
|
||||
inDataDBName = flag.String("datadb_name", config.CgrConfig().DataDbName, "The name/number of the DataDb to connect to.")
|
||||
inDataDBUser = flag.String("datadb_user", config.CgrConfig().DataDbUser, "The DataDb user to sign in as.")
|
||||
inDataDBPass = flag.String("datadb_passwd", config.CgrConfig().DataDbPass, "The DataDb user's password.")
|
||||
|
||||
inStorDBType = flag.String("in_stordb_type", "", "The type of the storDb Database <mysql|postgres>")
|
||||
inStorDBHost = flag.String("in_stordb_host", config.CgrConfig().StorDBHost, "The storDb host to connect to.")
|
||||
inStorDBPort = flag.String("in_stordb_port", config.CgrConfig().StorDBPort, "The storDb port to bind to.")
|
||||
inStorDBName = flag.String("in_stordb_name", config.CgrConfig().StorDBName, "The name/number of the storDb to connect to.")
|
||||
inStorDBUser = flag.String("in_stordb_user", config.CgrConfig().StorDBUser, "The storDb user to sign in as.")
|
||||
inStorDBPass = flag.String("in_stordb_passwd", config.CgrConfig().StorDBPass, "The storDb user's password.")
|
||||
inStorDBType = flag.String("stordb_type", "", "The type of the storDb Database <mysql|postgres>")
|
||||
inStorDBHost = flag.String("stordb_host", config.CgrConfig().StorDBHost, "The storDb host to connect to.")
|
||||
inStorDBPort = flag.String("stordb_port", config.CgrConfig().StorDBPort, "The storDb port to bind to.")
|
||||
inStorDBName = flag.String("stordb_name", config.CgrConfig().StorDBName, "The name/number of the storDb to connect to.")
|
||||
inStorDBUser = flag.String("stordb_user", config.CgrConfig().StorDBUser, "The storDb user to sign in as.")
|
||||
inStorDBPass = flag.String("stordb_passwd", config.CgrConfig().StorDBPass, "The storDb user's password.")
|
||||
|
||||
loadHistorySize = flag.Int("load_history_size", config.CgrConfig().LoadHistorySize, "Limit the number of records in the load history")
|
||||
inLoadHistorySize = flag.Int("in_load_history_size", 0, "Limit the number of records in the load history")
|
||||
|
||||
dbDataEncoding = flag.String("dbData_encoding", config.CgrConfig().DBDataEncoding, "The encoding used to store object Data in strings")
|
||||
inDBDataEncoding = flag.String("in_dbData_encoding", "", "The encoding used to store object Data in strings")
|
||||
|
||||
@@ -705,7 +705,7 @@ func (csvs *CSVStorage) GetTPFilters(tpid, id string) ([]*utils.TPFilter, error)
|
||||
return tpFilter.AsTPFilter(), nil
|
||||
}
|
||||
|
||||
func (csvs *CSVStorage) GetTpIds(x string) ([]string, error) {
|
||||
func (csvs *CSVStorage) GetTpIds(colName string) ([]string, error) {
|
||||
return nil, utils.ErrNotImplemented
|
||||
}
|
||||
|
||||
|
||||
@@ -28,15 +28,15 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (ms *MongoStorage) GetTpIds(colname string) ([]string, error) {
|
||||
func (ms *MongoStorage) GetTpIds(colName string) ([]string, error) {
|
||||
tpidMap := make(map[string]bool)
|
||||
session := ms.session.Copy()
|
||||
db := session.DB(ms.db)
|
||||
defer session.Close()
|
||||
var tpids []string
|
||||
var err error
|
||||
cols := []string{colname}
|
||||
if colname == "" {
|
||||
cols := []string{colName}
|
||||
if colName == "" {
|
||||
cols, err = db.CollectionNames()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -120,45 +120,39 @@ func (self *SQLStorage) IsDBEmpty() (resp bool, err error) {
|
||||
|
||||
// update
|
||||
// Return a list with all TPids defined in the system, even if incomplete, isolated in some table.
|
||||
func (self *SQLStorage) GetTpIds(colname string) ([]string, error) {
|
||||
func (self *SQLStorage) GetTpIds(colName string) ([]string, error) {
|
||||
var rows *sql.Rows
|
||||
var err error
|
||||
if colname != "" {
|
||||
rows, err = self.Db.Query(
|
||||
fmt.Sprintf(" (SELECT tpid FROM %s)", colname))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
} else {
|
||||
rows, err = self.Db.Query(
|
||||
fmt.Sprintf(
|
||||
"(SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s)",
|
||||
utils.TBLTPTimings,
|
||||
utils.TBLTPDestinations,
|
||||
utils.TBLTPRates,
|
||||
utils.TBLTPDestinationRates,
|
||||
utils.TBLTPRatingPlans,
|
||||
utils.TBLTPRateProfiles,
|
||||
utils.TBLTPSharedGroups,
|
||||
utils.TBLTPCdrStats,
|
||||
utils.TBLTPLcrs,
|
||||
utils.TBLTPActions,
|
||||
utils.TBLTPActionTriggers,
|
||||
utils.TBLTPAccountActions,
|
||||
utils.TBLTPDerivedChargers,
|
||||
utils.TBLTPUsers,
|
||||
utils.TBLTPAliases,
|
||||
utils.TBLTPResources,
|
||||
utils.TBLTPStats,
|
||||
utils.TBLTPThresholds,
|
||||
utils.TBLTPFilters,
|
||||
utils.TBLTPActionPlans))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
qryStr := fmt.Sprintf(" (SELECT tpid FROM %s)", colName)
|
||||
if colName == "" {
|
||||
qryStr = fmt.Sprintf(
|
||||
"(SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s)",
|
||||
utils.TBLTPTimings,
|
||||
utils.TBLTPDestinations,
|
||||
utils.TBLTPRates,
|
||||
utils.TBLTPDestinationRates,
|
||||
utils.TBLTPRatingPlans,
|
||||
utils.TBLTPRateProfiles,
|
||||
utils.TBLTPSharedGroups,
|
||||
utils.TBLTPCdrStats,
|
||||
utils.TBLTPLcrs,
|
||||
utils.TBLTPActions,
|
||||
utils.TBLTPActionTriggers,
|
||||
utils.TBLTPAccountActions,
|
||||
utils.TBLTPDerivedChargers,
|
||||
utils.TBLTPUsers,
|
||||
utils.TBLTPAliases,
|
||||
utils.TBLTPResources,
|
||||
utils.TBLTPStats,
|
||||
utils.TBLTPThresholds,
|
||||
utils.TBLTPFilters,
|
||||
utils.TBLTPActionPlans)
|
||||
}
|
||||
rows, err = self.Db.Query(qryStr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
ids := make([]string, 0)
|
||||
i := 0
|
||||
for rows.Next() {
|
||||
|
||||
Reference in New Issue
Block a user