mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
loading rates from db
This commit is contained in:
@@ -49,17 +49,17 @@ var (
|
||||
dataPath = flag.String("path", ".", "The path containing the data files")
|
||||
version = flag.Bool("version", false, "Prints the application version.")
|
||||
|
||||
destinationsFn = "Destinations.csv"
|
||||
ratesFn = "Rates.csv"
|
||||
destinationRatesFn = "DestinationRates.csv"
|
||||
timingsFn = "Timings.csv"
|
||||
ratetimingsFn = "DestinationRateTimings.csv"
|
||||
ratingprofilesFn = "RatingProfiles.csv"
|
||||
actionsFn = "Actions.csv"
|
||||
actiontimingsFn = "ActionTimings.csv"
|
||||
actiontriggersFn = "ActionTriggers.csv"
|
||||
accountactionsFn = "AccountActions.csv"
|
||||
sep rune
|
||||
destinationsFn = "Destinations.csv"
|
||||
ratesFn = "Rates.csv"
|
||||
destinationratesFn = "DestinationRates.csv"
|
||||
timingsFn = "Timings.csv"
|
||||
destinationratetimingsFn = "DestinationRateTimings.csv"
|
||||
ratingprofilesFn = "RatingProfiles.csv"
|
||||
actionsFn = "Actions.csv"
|
||||
actiontimingsFn = "ActionTimings.csv"
|
||||
actiontriggersFn = "ActionTriggers.csv"
|
||||
accountactionsFn = "AccountActions.csv"
|
||||
sep rune
|
||||
)
|
||||
|
||||
type validator struct {
|
||||
@@ -109,15 +109,18 @@ func main() {
|
||||
&validator{destinationsFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\d+.?\d*){1}$`),
|
||||
"Tag[0-9A-Za-z_],Prefix[0-9]"},
|
||||
&validator{ratesFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){2}(?:\d+.?\d*,?){4}$`),
|
||||
"Tag[0-9A-Za-z_],DestinationsTag[0-9A-Za-z_],ConnectFee[0-9.],Price[0-9.],PricedUnits[0-9.],RateIncrement[0-9.]"},
|
||||
&validator{timingsFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\*all\s*,\s*|(?:\d{1,4};?)+\s*,\s*|\s*,\s*){4}(?:\d{2}:\d{2}:\d{2}|\*asap){1}$`),
|
||||
"Tag[0-9A-Za-z_],Years[0-9;]|*all|<empty>,Months[0-9;]|*all|<empty>,MonthDays[0-9;]|*all|<empty>,WeekDays[0-9;]|*all|<empty>,Time[0-9:]|*asap(00:00:00)"},
|
||||
&validator{ratetimingsFn,
|
||||
&validator{ratesFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){2}(?:\d+.?\d*,?){4}$`),
|
||||
"Tag[0-9A-Za-z_],ConnectFee[0-9.],Price[0-9.],PricedUnits[0-9.],RateIncrement[0-9.]"},
|
||||
&validator{destinationratesFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){2}(?:\d+.?\d*,?){4}$`),
|
||||
"Tag[0-9A-Za-z_],DestinationsTag[0-9A-Za-z_],RateTag[0-9A-Za-z_]"},
|
||||
&validator{destinationratetimingsFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){3}(?:\d+.?\d*){1}$`),
|
||||
"Tag[0-9A-Za-z_],RatesTag[0-9A-Za-z_],TimingProfile[0-9A-Za-z_],Weight[0-9.]"},
|
||||
"Tag[0-9A-Za-z_],DestinationRatesTag[0-9A-Za-z_],TimingProfile[0-9A-Za-z_],Weight[0-9.]"},
|
||||
&validator{ratingprofilesFn,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\d+\s*,\s*){1}(?:OUT\s*,\s*|IN\s*,\s*){1}(?:\*all\s*,\s*|[\w:\.]+\s*,\s*){1}(?:\w*\s*,\s*){1}(?:\w+\s*,\s*){1}(?:\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z){1}$`),
|
||||
"Tenant[0-9A-Za-z_],TOR[0-9],Direction OUT|IN,Subject[0-9A-Za-z_:.]|*all,RatesFallbackSubject[0-9A-Za-z_]|<empty>,RatesTimingTag[0-9A-Za-z_],ActivationTime[[0-9T:X]] (2012-01-01T00:00:00Z)"},
|
||||
@@ -152,15 +155,19 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = loader.LoadRates()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = loader.LoadTimings()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = loader.LoadRateTimings()
|
||||
err = loader.LoadRates()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = loader.LoadDestinationRates()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = loader.LoadDestinationRateTimings()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -35,8 +35,9 @@ type DbReader struct {
|
||||
actionsTriggers map[string][]*ActionTrigger
|
||||
accountActions []*UserBalance
|
||||
destinations []*Destination
|
||||
rates map[string][]*Rate
|
||||
timings map[string]*Timing
|
||||
rates map[string]*Rate
|
||||
destinationRates map[string][]*DestinationRate
|
||||
activationPeriods map[string]*ActivationPeriod
|
||||
ratingProfiles map[string]*RatingProfile
|
||||
}
|
||||
@@ -124,18 +125,23 @@ func (dbr *DbReader) LoadDestinations() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (dbr *DbReader) LoadRates() (err error) {
|
||||
dbr.rates, err = dbr.storDB.GetTpRates(dbr.tpid, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (dbr *DbReader) LoadTimings() (err error) {
|
||||
dbr.timings, err = dbr.storDB.GetTpTimings(dbr.tpid, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (dbr *DbReader) LoadRateTimings() error {
|
||||
rts, err := dbr.storDB.GetTpRateTimings(dbr.tpid, "")
|
||||
func (dbr *DbReader) LoadRates() (err error) {
|
||||
dbr.rates, err = dbr.storDB.GetTpRates(dbr.tpid, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (dbr *DbReader) LoadDestinationRates() (err error) {
|
||||
dbr.destinationRates, err = dbr.storDB.GetTpDestinationRates(dbr.tpid, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (dbr *DbReader) LoadDestinationRateTimings() error {
|
||||
rts, err := dbr.storDB.GetTpDestinationRateTimings(dbr.tpid, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -145,16 +151,16 @@ func (dbr *DbReader) LoadRateTimings() error {
|
||||
return errors.New(fmt.Sprintf("Could not get timing for tag %v", rt.TimingsTag))
|
||||
}
|
||||
rt.timing = t
|
||||
rs, exists := dbr.rates[rt.RatesTag]
|
||||
drs, exists := dbr.destinationRates[rt.DestinationRatesTag]
|
||||
if !exists {
|
||||
return errors.New(fmt.Sprintf("Could not find rate for tag %v", rt.RatesTag))
|
||||
return errors.New(fmt.Sprintf("Could not find destination rate for tag %v", rt.DestinationRatesTag))
|
||||
}
|
||||
for _, r := range rs {
|
||||
for _, dr := range drs {
|
||||
_, exists := dbr.activationPeriods[rt.Tag]
|
||||
if !exists {
|
||||
dbr.activationPeriods[rt.Tag] = &ActivationPeriod{}
|
||||
}
|
||||
dbr.activationPeriods[rt.Tag].AddIntervalIfNotPresent(rt.GetInterval(r))
|
||||
dbr.activationPeriods[rt.Tag].AddIntervalIfNotPresent(rt.GetInterval(dr))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -198,7 +204,7 @@ func (dbr *DbReader) LoadRatingProfileByTag(tag string) (*RatingProfile, error)
|
||||
if err != nil {
|
||||
return nil, errors.New(fmt.Sprintf("Cannot parse activation time from %v", ratingProfile.activationTime))
|
||||
}
|
||||
rtm, err := dbr.storDB.GetTpRateTimings(dbr.tpid, ratingProfile.ratesTimingTag)
|
||||
rtm, err := dbr.storDB.GetTpDestinationRateTimings(dbr.tpid, ratingProfile.ratesTimingTag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -208,11 +214,11 @@ func (dbr *DbReader) LoadRatingProfileByTag(tag string) (*RatingProfile, error)
|
||||
return nil, err
|
||||
}
|
||||
rateTiming.timing = tm[rateTiming.TimingsTag]
|
||||
rm, err := dbr.storDB.GetTpRates(dbr.tpid, rateTiming.RatesTag)
|
||||
rm, err := dbr.storDB.GetTpDestinationRates(dbr.tpid, rateTiming.DestinationRatesTag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, rate := range rm[rateTiming.RatesTag] {
|
||||
for _, rate := range rm[rateTiming.DestinationRatesTag] {
|
||||
_, exists := activationPeriods[rateTiming.Tag]
|
||||
if !exists {
|
||||
activationPeriods[rateTiming.Tag] = &ActivationPeriod{}
|
||||
|
||||
@@ -81,6 +81,7 @@ func NewRate(tag, connectFee, price, pricedUnits, rateIncrements string) (r *Rat
|
||||
type DestinationRate struct {
|
||||
Tag string
|
||||
DestinationsTag string
|
||||
RateTag string
|
||||
Rate *Rate
|
||||
}
|
||||
|
||||
@@ -103,23 +104,23 @@ func NewTiming(timeingInfo ...string) (rt *Timing) {
|
||||
}
|
||||
|
||||
type DestinationRateTiming struct {
|
||||
Tag string
|
||||
RatesTag string
|
||||
Weight float64
|
||||
TimingsTag string // intermediary used when loading from db
|
||||
timing *Timing
|
||||
Tag string
|
||||
DestinationRatesTag string
|
||||
Weight float64
|
||||
TimingsTag string // intermediary used when loading from db
|
||||
timing *Timing
|
||||
}
|
||||
|
||||
func NewDestinationRateTiming(ratesTag string, timing *Timing, weight string) (rt *DestinationRateTiming) {
|
||||
func NewDestinationRateTiming(destinationRatesTag string, timing *Timing, weight string) (rt *DestinationRateTiming) {
|
||||
w, err := strconv.ParseFloat(weight, 64)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing weight unit from: %v", weight)
|
||||
return
|
||||
}
|
||||
rt = &DestinationRateTiming{
|
||||
RatesTag: ratesTag,
|
||||
Weight: w,
|
||||
timing: timing,
|
||||
DestinationRatesTag: destinationRatesTag,
|
||||
Weight: w,
|
||||
timing: timing,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ type DataStorage interface {
|
||||
SetRatingProfile(*RatingProfile) error
|
||||
GetDestination(string) (*Destination, error)
|
||||
SetDestination(*Destination) error
|
||||
GetTPDestinationIds(string) ([]string,error)
|
||||
GetTPDestinationIds(string) ([]string, error)
|
||||
ExistsTPDestination(string, string) (bool, error)
|
||||
GetTPDestination(string, string) (*Destination, error)
|
||||
SetTPDestination(string, *Destination) error
|
||||
@@ -79,9 +79,10 @@ type DataStorage interface {
|
||||
GetCallCostLog(uuid, source string) (*CallCost, error)
|
||||
// loader functions
|
||||
GetTpDestinations(string, string) ([]*Destination, error)
|
||||
GetTpRates(string, string) (map[string][]*Rate, error)
|
||||
GetTpTimings(string, string) (map[string]*Timing, error)
|
||||
GetTpRateTimings(string, string) ([]*RateTiming, error)
|
||||
GetTpRates(string, string) (map[string]*Rate, error)
|
||||
GetTpDestinationRates(string, string) (map[string][]*DestinationRate, error)
|
||||
GetTpDestinationRateTimings(string, string) ([]*DestinationRateTiming, error)
|
||||
GetTpRatingProfiles(string, string) (map[string]*RatingProfile, error)
|
||||
GetTpActions(string, string) (map[string][]*Action, error)
|
||||
GetTpActionTimings(string, string) (map[string][]*ActionTiming, error)
|
||||
|
||||
@@ -77,7 +77,6 @@ func (ms *MapStorage) GetTPDestinationIds(tpid string) ([]string, error) {
|
||||
return nil, errors.New(utils.ERR_NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
|
||||
func (ms *MapStorage) ExistsTPDestination(tpid, destTag string) (bool, error) {
|
||||
return false, errors.New(utils.ERR_NOT_IMPLEMENTED)
|
||||
}
|
||||
@@ -218,15 +217,19 @@ func (ms *MapStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (ms *MapStorage) GetTpRates(tpid, tag string) (map[string][]*Rate, error) {
|
||||
func (ms *MapStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MapStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MapStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MapStorage) GetTpRateTimings(tpid, tag string) ([]*RateTiming, error) {
|
||||
func (ms *MapStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (ms *MapStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -164,7 +164,6 @@ func (ms *MongoStorage) SetTPDestination(tpid string, dest *Destination) error {
|
||||
return errors.New(utils.ERR_NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
|
||||
func (ms *MongoStorage) GetActions(key string) (as Actions, err error) {
|
||||
result := AcKeyValue{}
|
||||
err = ms.db.C("actions").Find(bson.M{"key": key}).One(&result)
|
||||
@@ -248,13 +247,16 @@ func (ms *MongoStorage) GetTpDestinations(tpid, tag string) ([]*Destination, err
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (ms *MongoStorage) GetTpRates(tpid, tag string) (map[string][]*Rate, error) {
|
||||
func (ms *MongoStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MongoStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MongoStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MongoStorage) GetTpRateTimings(tpid, tag string) ([]*RateTiming, error) {
|
||||
func (ms *MongoStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (ms *MongoStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error) {
|
||||
|
||||
@@ -119,7 +119,6 @@ func (rs *RedisStorage) SetTPDestination(tpid string, dest *Destination) error {
|
||||
return errors.New(utils.ERR_NOT_IMPLEMENTED)
|
||||
}
|
||||
|
||||
|
||||
func (rs *RedisStorage) GetActions(key string) (as Actions, err error) {
|
||||
var values string
|
||||
if values, err = rs.db.Get(ACTION_PREFIX + key); err == nil {
|
||||
@@ -253,13 +252,17 @@ func (rs *RedisStorage) GetTpDestinations(tpid, tag string) ([]*Destination, err
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (rs *RedisStorage) GetTpRates(tpid, tag string) (map[string][]*Rate, error) {
|
||||
func (rs *RedisStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (ms *RedisStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (rs *RedisStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (rs *RedisStorage) GetTpRateTimings(tpid, tag string) ([]*RateTiming, error) {
|
||||
func (rs *RedisStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (rs *RedisStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error) {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (sql *SQLStorage) GetTPDestinationIds(tpid string) ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
ids:= []string{}
|
||||
ids := []string{}
|
||||
i := 0
|
||||
for rows.Next() {
|
||||
i++ //Keep here a reference so we know we got at least one prefix
|
||||
@@ -112,8 +112,8 @@ func (sql *SQLStorage) GetTPDestination(tpid, destTag string) (*Destination, err
|
||||
}
|
||||
|
||||
func (sql *SQLStorage) SetTPDestination(tpid string, dest *Destination) error {
|
||||
for _,prefix := range dest.Prefixes {
|
||||
if _,err := sql.Db.Exec(fmt.Sprintf("INSERT INTO %s (tpid, tag, prefix) VALUES( '%s','%s','%s')",utils.TBL_TP_DESTINATIONS, tpid, dest.Id, prefix));err!=nil {
|
||||
for _, prefix := range dest.Prefixes {
|
||||
if _, err := sql.Db.Exec(fmt.Sprintf("INSERT INTO %s (tpid, tag, prefix) VALUES( '%s','%s','%s')", utils.TBL_TP_DESTINATIONS, tpid, dest.Id, prefix)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -269,8 +269,8 @@ func (sql *SQLStorage) GetTpDestinations(tpid, tag string) ([]*Destination, erro
|
||||
return dests, rows.Err()
|
||||
}
|
||||
|
||||
func (sql *SQLStorage) GetTpRates(tpid, tag string) (map[string][]*Rate, error) {
|
||||
rts := make(map[string][]*Rate)
|
||||
func (sql *SQLStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error) {
|
||||
rts := make(map[string]*Rate)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid=%s", utils.TBL_TP_RATES, tpid)
|
||||
if tag != "" {
|
||||
q += "AND tag=" + tag
|
||||
@@ -281,21 +281,49 @@ func (sql *SQLStorage) GetTpRates(tpid, tag string) (map[string][]*Rate, error)
|
||||
}
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var tpid, tag, destinations_tag string
|
||||
var tpid, tag string
|
||||
var connect_fee, rate, priced_units, rate_increments float64
|
||||
if err := rows.Scan(&id, &tpid, &tag, &destinations_tag, &connect_fee, &rate, &priced_units, &rate_increments); err != nil {
|
||||
if err := rows.Scan(&id, &tpid, &tag, &connect_fee, &rate, &priced_units, &rate_increments); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r := &Rate{
|
||||
DestinationsTag: destinations_tag,
|
||||
ConnectFee: connect_fee,
|
||||
Price: rate,
|
||||
PricedUnits: priced_units,
|
||||
RateIncrements: rate_increments,
|
||||
Tag: tag,
|
||||
ConnectFee: connect_fee,
|
||||
Price: rate,
|
||||
PricedUnits: priced_units,
|
||||
RateIncrements: rate_increments,
|
||||
}
|
||||
|
||||
rts[tag] = append(rts[tag], r)
|
||||
rts[tag] = r
|
||||
}
|
||||
return rts, rows.Err()
|
||||
}
|
||||
|
||||
func (sql *SQLStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error) {
|
||||
rts := make(map[string][]*DestinationRate)
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid=%s", utils.TBL_TP_DESTINATION_RATES, tpid)
|
||||
if tag != "" {
|
||||
q += "AND tag=" + tag
|
||||
}
|
||||
rows, err := sql.Db.Query(q, tpid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var tpid, tag, destinations_tag, rate_tag string
|
||||
if err := rows.Scan(&id, &tpid, &tag, destinations_tag, rate_tag); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dr := &DestinationRate{
|
||||
Tag: tag,
|
||||
DestinationsTag: destinations_tag,
|
||||
RateTag: rate_tag,
|
||||
}
|
||||
|
||||
rts[tag] = append(rts[tag], dr)
|
||||
}
|
||||
return rts, rows.Err()
|
||||
}
|
||||
@@ -321,9 +349,9 @@ func (sql *SQLStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error
|
||||
return tms, rows.Err()
|
||||
}
|
||||
|
||||
func (sql *SQLStorage) GetTpRateTimings(tpid, tag string) ([]*RateTiming, error) {
|
||||
var rts []*RateTiming
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid=%s", utils.TBL_TP_RATE_TIMINGS, tpid)
|
||||
func (sql *SQLStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) {
|
||||
var rts []*DestinationRateTiming
|
||||
q := fmt.Sprintf("SELECT * FROM %s WHERE tpid=%s", utils.TBL_TP_DESTINATION_RATE_TIMINGS, tpid)
|
||||
if tag != "" {
|
||||
q += "AND tag=" + tag
|
||||
}
|
||||
@@ -334,15 +362,15 @@ func (sql *SQLStorage) GetTpRateTimings(tpid, tag string) ([]*RateTiming, error)
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var weight float64
|
||||
var tpid, tag, rates_tag, timings_tag string
|
||||
if err := rows.Scan(&id, &tpid, &tag, &rates_tag, &timings_tag, &weight); err != nil {
|
||||
var tpid, tag, destination_rates_tag, timings_tag string
|
||||
if err := rows.Scan(&id, &tpid, &tag, &destination_rates_tag, &timings_tag, &weight); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rt := &RateTiming{
|
||||
Tag: tag,
|
||||
RatesTag: rates_tag,
|
||||
Weight: weight,
|
||||
TimingsTag: timings_tag,
|
||||
rt := &DestinationRateTiming{
|
||||
Tag: tag,
|
||||
DestinationRatesTag: destination_rates_tag,
|
||||
Weight: weight,
|
||||
TimingsTag: timings_tag,
|
||||
}
|
||||
rts = append(rts, rt)
|
||||
}
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
package utils
|
||||
|
||||
const (
|
||||
LOCALHOST = "127.0.0.1"
|
||||
FSCDR_FILE_CSV = "freeswitch_file_csv"
|
||||
FSCDR_HTTP_JSON = "freeswitch_http_json"
|
||||
NOT_IMPLEMENTED = "not implemented"
|
||||
PREPAID = "prepaid"
|
||||
POSTPAID = "postpaid"
|
||||
PSEUDOPREPAID = "pseudoprepaid"
|
||||
RATED = "rated"
|
||||
ERR_NOT_IMPLEMENTED = "NOT_IMPLEMENTED"
|
||||
ERR_SERVER_ERROR = "SERVER_ERROR"
|
||||
ERR_NOT_FOUND = "NOT_FOUND"
|
||||
ERR_MANDATORY_IE_MISSING = "MANDATORY_IE_MISSING"
|
||||
ERR_DUPLICATE = "DUPLICATE"
|
||||
TBL_TP_TIMINGS = "tp_timings"
|
||||
TBL_TP_DESTINATIONS = "tp_destinations"
|
||||
TBL_TP_RATES = "tp_rates"
|
||||
TBL_TP_RATE_TIMINGS = "tp_rate_timings"
|
||||
TBL_TP_RATE_PROFILES = "tp_rate_profiles"
|
||||
TBL_TP_ACTIONS = "tp_actions"
|
||||
TBL_TP_ACTION_TIMINGS = "tp_action_timings"
|
||||
TBL_TP_ACTION_TRIGGERS = "tp_action_triggers"
|
||||
TBL_TP_ACCOUNT_ACTIONS = "tp_account_actions"
|
||||
LOCALHOST = "127.0.0.1"
|
||||
FSCDR_FILE_CSV = "freeswitch_file_csv"
|
||||
FSCDR_HTTP_JSON = "freeswitch_http_json"
|
||||
NOT_IMPLEMENTED = "not implemented"
|
||||
PREPAID = "prepaid"
|
||||
POSTPAID = "postpaid"
|
||||
PSEUDOPREPAID = "pseudoprepaid"
|
||||
RATED = "rated"
|
||||
ERR_NOT_IMPLEMENTED = "NOT_IMPLEMENTED"
|
||||
ERR_SERVER_ERROR = "SERVER_ERROR"
|
||||
ERR_NOT_FOUND = "NOT_FOUND"
|
||||
ERR_MANDATORY_IE_MISSING = "MANDATORY_IE_MISSING"
|
||||
ERR_DUPLICATE = "DUPLICATE"
|
||||
TBL_TP_TIMINGS = "tp_timings"
|
||||
TBL_TP_DESTINATIONS = "tp_destinations"
|
||||
TBL_TP_RATES = "tp_rates"
|
||||
TBL_TP_DESTINATION_RATES = "tp_destination_rates"
|
||||
TBL_TP_DESTINATION_RATE_TIMINGS = "tp_destination_rate_timings"
|
||||
TBL_TP_RATE_PROFILES = "tp_rate_profiles"
|
||||
TBL_TP_ACTIONS = "tp_actions"
|
||||
TBL_TP_ACTION_TIMINGS = "tp_action_timings"
|
||||
TBL_TP_ACTION_TRIGGERS = "tp_action_triggers"
|
||||
TBL_TP_ACCOUNT_ACTIONS = "tp_account_actions"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user