mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -147,18 +147,14 @@ func (self *Apier) ExecuteAction(attr *AttrExecuteAction, reply *float64) error
|
||||
}
|
||||
|
||||
type AttrSetRatingProfile struct {
|
||||
Direction string
|
||||
Tenant string
|
||||
TOR string
|
||||
Subject string
|
||||
TPID string
|
||||
TPID string
|
||||
RateProfileId string
|
||||
}
|
||||
|
||||
func (self *Apier) SetRatingProfile(attr *AttrSetRatingProfile, reply *float64) error {
|
||||
tag := fmt.Sprintf("%s:%s:%s:%s", attr.Direction, attr.Tenant, attr.TOR, attr.Subject)
|
||||
dbReader := rater.NewDbReader(self.StorDb, self.DataDb, attr.TPID)
|
||||
|
||||
newRP, err := dbReader.LoadRatingProfileByTag(tag)
|
||||
newRP, err := dbReader.LoadRatingProfileByTag(attr.RateProfileId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -338,11 +338,8 @@ Sets the rating profile for the specified subject.
|
||||
::
|
||||
|
||||
type AttrSetRatingProfile struct {
|
||||
Direction string
|
||||
Tenant string
|
||||
TOR string
|
||||
Subject string
|
||||
TPID string
|
||||
TPID string
|
||||
RatingProfileId string
|
||||
}
|
||||
|
||||
Example
|
||||
|
||||
@@ -29,10 +29,10 @@ const (
|
||||
)
|
||||
|
||||
type RatingProfile struct {
|
||||
Id string
|
||||
FallbackKey string
|
||||
DestinationMap map[string][]*ActivationPeriod
|
||||
ratesTimingTag, activationTime string // used only for loading
|
||||
Id string
|
||||
FallbackKey string
|
||||
DestinationMap map[string][]*ActivationPeriod
|
||||
tag, ratesTimingTag, activationTime string // used only for loading
|
||||
}
|
||||
|
||||
// Adds an activation period that applyes to current rating profile if not already present.
|
||||
|
||||
@@ -282,7 +282,7 @@ func (self *SQLStorage) SetTPDestinationRate(dr *utils.TPDestinationRate) error
|
||||
// Using multiple values in query to spare some network processing time
|
||||
qry := fmt.Sprintf("INSERT INTO %s (tpid, tag, destinations_tag, rates_tag) VALUES ", utils.TBL_TP_DESTINATION_RATES)
|
||||
for idx, drPair := range dr.DestinationRates {
|
||||
if idx!=0 { //Consecutive values after the first will be prefixed with "," as separator
|
||||
if idx != 0 { //Consecutive values after the first will be prefixed with "," as separator
|
||||
qry += ","
|
||||
}
|
||||
qry += fmt.Sprintf("('%s','%s','%s','%s')", dr.TPid, dr.DestinationRateId, drPair.DestinationId, drPair.RateId)
|
||||
@@ -355,7 +355,7 @@ func (self *SQLStorage) SetTPDestRateTiming(drt *utils.TPDestRateTiming) error {
|
||||
// Using multiple values in query to spare some network processing time
|
||||
qry := fmt.Sprintf("INSERT INTO %s (tpid, tag, destrates_tag, timing_tag, weight) VALUES ", utils.TBL_TP_DESTRATE_TIMINGS)
|
||||
for idx, drtPair := range drt.DestRateTimings {
|
||||
if idx!=0 { //Consecutive values after the first will be prefixed with "," as separator
|
||||
if idx != 0 { //Consecutive values after the first will be prefixed with "," as separator
|
||||
qry += ","
|
||||
}
|
||||
qry += fmt.Sprintf("('%s','%s','%s','%s',%f)", drt.TPid, drt.DestRateTimingId, drtPair.DestRatesId, drtPair.TimingId, drtPair.Weight)
|
||||
@@ -382,7 +382,7 @@ func (self *SQLStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRa
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
drt.DestRateTimings = append(drt.DestRateTimings, utils.DestRateTiming{drTag, timingTag,weight})
|
||||
drt.DestRateTimings = append(drt.DestRateTimings, utils.DestRateTiming{drTag, timingTag, weight})
|
||||
}
|
||||
if i == 0 {
|
||||
return nil, nil
|
||||
@@ -779,15 +779,15 @@ func (self *SQLStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*Ratin
|
||||
}
|
||||
for rows.Next() {
|
||||
var id int
|
||||
var tpid, tenant, tor, direction, subject, fallback_subject, rates_timing_tag, activation_time string
|
||||
var tpid, tag, tenant, tor, direction, subject, fallback_subject, rates_timing_tag, activation_time string
|
||||
|
||||
if err := rows.Scan(&id, &tpid, &tenant, &tor, &direction, &subject, &fallback_subject, &rates_timing_tag, &activation_time); err != nil {
|
||||
if err := rows.Scan(&id, &tag, &tpid, &tenant, &tor, &direction, &subject, &fallback_subject, &rates_timing_tag, &activation_time); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
key := fmt.Sprintf("%s:%s:%s:%s", direction, tenant, tor, subject)
|
||||
rp, ok := rpfs[key]
|
||||
if !ok {
|
||||
rp = &RatingProfile{Id: key}
|
||||
if !ok || rp.tag != tag {
|
||||
rp = &RatingProfile{Id: key, tag: tag}
|
||||
rpfs[key] = rp
|
||||
}
|
||||
rp.ratesTimingTag = rates_timing_tag
|
||||
|
||||
Reference in New Issue
Block a user