mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
moved weight from rates to ratetimings
This commit is contained in:
@@ -36,7 +36,7 @@ var (
|
||||
destinationsFn = flag.String("destinations", "Destinations.csv", "Destinations file")
|
||||
ratesFn = flag.String("rates", "Rates.csv", "Rates file")
|
||||
timingsFn = flag.String("timings", "Timings.csv", "Timings file")
|
||||
ratestimingsFn = flag.String("ratestimings", "RatesTimings.csv", "Rates timings file")
|
||||
ratetimingsFn = flag.String("ratetimings", "RateTimings.csv", "Rates timings file")
|
||||
ratingprofilesFn = flag.String("ratingprofiles", "RatingProfiles.csv", "Rating profiles file")
|
||||
actionsFn = flag.String("actions", "Actions.csv", "Actions file")
|
||||
actiontimingsFn = flag.String("actiontimings", "ActionTimings.csv", "Actions timings file")
|
||||
@@ -88,7 +88,7 @@ func main() {
|
||||
loadDestinations()
|
||||
loadRates()
|
||||
loadTimings()
|
||||
loadRatesTimings()
|
||||
loadRateTimings()
|
||||
loadRatingProfiles()
|
||||
loadActions()
|
||||
loadActionTimings()
|
||||
|
||||
@@ -27,11 +27,11 @@ import (
|
||||
)
|
||||
|
||||
type Rate struct {
|
||||
DestinationsTag string
|
||||
ConnectFee, Price, BillingUnit, Weight float64
|
||||
DestinationsTag string
|
||||
ConnectFee, Price, BillingUnit float64
|
||||
}
|
||||
|
||||
func NewRate(destinationsTag, connectFee, price, billingUnit, weight string) (r *Rate, err error) {
|
||||
func NewRate(destinationsTag, connectFee, price, billingUnit string) (r *Rate, err error) {
|
||||
cf, err := strconv.ParseFloat(connectFee, 64)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing connect fee from: %v", connectFee)
|
||||
@@ -47,17 +47,11 @@ func NewRate(destinationsTag, connectFee, price, billingUnit, weight string) (r
|
||||
log.Printf("Error parsing billing unit from: %v", billingUnit)
|
||||
return
|
||||
}
|
||||
w, err := strconv.ParseFloat(weight, 64)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing weight from: %v", weight)
|
||||
return
|
||||
}
|
||||
r = &Rate{
|
||||
DestinationsTag: destinationsTag,
|
||||
ConnectFee: cf,
|
||||
Price: p,
|
||||
BillingUnit: bu,
|
||||
Weight: w,
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -85,12 +79,19 @@ func NewTiming(timeingInfo ...string) (rt *Timing) {
|
||||
|
||||
type RateTiming struct {
|
||||
RatesTag string
|
||||
Weight float64
|
||||
timing *Timing
|
||||
}
|
||||
|
||||
func NewRateTiming(ratesTag string, timing *Timing) (rt *RateTiming) {
|
||||
func NewRateTiming(ratesTag string, timing *Timing, weight string) (rt *RateTiming) {
|
||||
w, err := strconv.ParseFloat(weight, 64)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing weight unit from: %v", weight)
|
||||
return
|
||||
}
|
||||
rt = &RateTiming{
|
||||
RatesTag: ratesTag,
|
||||
Weight: w,
|
||||
timing: timing,
|
||||
}
|
||||
return
|
||||
@@ -102,10 +103,10 @@ func (rt *RateTiming) GetInterval(r *Rate) (i *timespans.Interval) {
|
||||
MonthDays: rt.timing.MonthDays,
|
||||
WeekDays: rt.timing.WeekDays,
|
||||
StartTime: rt.timing.StartTime,
|
||||
Weight: rt.Weight,
|
||||
ConnectFee: r.ConnectFee,
|
||||
Price: r.Price,
|
||||
BillingUnit: r.BillingUnit,
|
||||
Weight: r.Weight,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ func loadRates() {
|
||||
// skip header line
|
||||
continue
|
||||
}
|
||||
r, err := NewRate(record[1], record[2], record[3], record[4], record[5])
|
||||
r, err := NewRate(record[1], record[2], record[3], record[4])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -113,8 +113,8 @@ func loadTimings() {
|
||||
}
|
||||
}
|
||||
|
||||
func loadRatesTimings() {
|
||||
fp, err := os.Open(*ratestimingsFn)
|
||||
func loadRateTimings() {
|
||||
fp, err := os.Open(*ratetimingsFn)
|
||||
if err != nil {
|
||||
log.Printf("Could not open rates timings file: %v", err)
|
||||
return
|
||||
@@ -136,8 +136,7 @@ func loadRatesTimings() {
|
||||
continue
|
||||
}
|
||||
for _, t := range ts {
|
||||
rt := NewRateTiming(record[1], t)
|
||||
//ratesTimings[tag] = append(ratesTimings[tag], rt)
|
||||
rt := NewRateTiming(record[1], t, record[3])
|
||||
rs, exists := rates[record[1]]
|
||||
if !exists {
|
||||
log.Printf("Could not rate for tag %v", record[2])
|
||||
|
||||
9
data/RateTimings.csv
Normal file
9
data/RateTimings.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
Tag,RatesTag,TimingProfile,Weight
|
||||
STANDARD,RT_STANDARD,WORKDAYS_00,10
|
||||
STANDARD,RT_STD_WEEKEND,WORKDAYS_18,10
|
||||
STANDARD,RT_STD_WEEKEND,WEEKENDS,10
|
||||
PREMIUM,RT_STD_WEEKEND,WEEKENDS,10
|
||||
DEFAULT,RT_DEFAULT,WORKDAYS_00,10
|
||||
EVENING,P1,WORKDAYS_00,10
|
||||
EVENING,P2,WORKDAYS_18,10
|
||||
EVENING,P2,WEEKENDS,10
|
||||
|
@@ -1,9 +1,9 @@
|
||||
Tag,DestinationsTag,ConnectFee,Price,BillingUnit,Weight
|
||||
RT_STANDARD,GERMANY,0,0.2,1,10
|
||||
RT_STANDARD,GERMANY_O2,0,0.1,1,10
|
||||
RT_STANDARD,GERMANY_PREMIUM,0,0.1,1,10
|
||||
RT_DEFAULT,ALL,0,0.1,1,10
|
||||
RT_STD_WEEKEND,GERMANY,0,0.1,1,10
|
||||
RT_STD_WEEKEND,GERMANY_O2,0,0.05,1,10
|
||||
P1,NAT,0,1,1,10
|
||||
P2,NAT,0,0.5,1,10
|
||||
Tag,DestinationsTag,ConnectFee,Price,BillingUnit
|
||||
RT_STANDARD,GERMANY,0,0.2,1
|
||||
RT_STANDARD,GERMANY_O2,0,0.1,1
|
||||
RT_STANDARD,GERMANY_PREMIUM,0,0.1,1
|
||||
RT_DEFAULT,ALL,0,0.1,1
|
||||
RT_STD_WEEKEND,GERMANY,0,0.1,1
|
||||
RT_STD_WEEKEND,GERMANY_O2,0,0.05,1
|
||||
P1,NAT,0,1,1
|
||||
P2,NAT,0,0.5,1
|
||||
|
@@ -1,9 +0,0 @@
|
||||
Tag,RatesTag,TimingProfile
|
||||
STANDARD,RT_STANDARD,WORKDAYS_00
|
||||
STANDARD,RT_STD_WEEKEND,WORKDAYS_18
|
||||
STANDARD,RT_STD_WEEKEND,WEEKENDS
|
||||
PREMIUM,RT_STD_WEEKEND,WEEKENDS
|
||||
DEFAULT,RT_DEFAULT,WORKDAYS_00
|
||||
EVENING,P1,WORKDAYS_00
|
||||
EVENING,P2,WORKDAYS_18
|
||||
EVENING,P2,WEEKENDS
|
||||
|
@@ -18,40 +18,43 @@ The rates profile describes the prices to be applied for various calls to variou
|
||||
| CUSTOMER_1 | 0 | OUT | rif:from:tm | danb | STANDARD | 2012-02-28T00:00:00Z |
|
||||
+------------+-----+-----------+-------------+----------------------+----------------+----------------------+
|
||||
|
||||
+ Tenant
|
||||
Tenant
|
||||
Used to distinguish between carriers if more than one share the same database in the CGRates system.
|
||||
+ TOR
|
||||
TOR
|
||||
Type of record specifies the kind of transmission this rate profile applies to.
|
||||
+ Direction
|
||||
Direction
|
||||
Can be IN or OUT for the INBOUND and OUTBOUND calls.
|
||||
+ Subject
|
||||
Subject
|
||||
The client/user for who this profile is detailing the rates.
|
||||
+ RatesFallbackSubject
|
||||
RatesFallbackSubject
|
||||
This specifies another profile to be used in case the call destination will not be found in the current profile. The same tenant, tor and direction will be used.
|
||||
+ RatesTimingTag
|
||||
RatesTimingTag
|
||||
Forwards to a tag described in the rates timing file to be used for this profile.
|
||||
+ ActivationTime
|
||||
ActivationTime
|
||||
Multiple rates timings/prices can be created for one profile with different activation times. When a call is made the appropriate profile(s) will be used to rate the call.
|
||||
|
||||
Rates timings
|
||||
Rates timing
|
||||
-------------
|
||||
|
||||
This file makes links between a ratings and timings so each of them can be described once and various combinations are made possible.
|
||||
|
||||
+----------+----------------+--------------+
|
||||
| Tag | RatesTag | TimingTag |
|
||||
+==========+================+==============+
|
||||
| STANDARD | RT_STANDARD | WORKDAYS_00 |
|
||||
+----------+----------------+--------------+
|
||||
| STANDARD | RT_STD_WEEKEND | WORKDAYS_18 |
|
||||
+----------+----------------+--------------+
|
||||
+----------+----------------+--------------+--------+
|
||||
| Tag | RatesTag | TimingTag | Weight |
|
||||
+==========+================+==============+========+
|
||||
| STANDARD | RT_STANDARD | WORKDAYS_00 | 10 |
|
||||
+----------+----------------+--------------+--------+
|
||||
| STANDARD | RT_STD_WEEKEND | WORKDAYS_18 | 10 |
|
||||
+----------+----------------+--------------+--------+
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this rates timing will be referenced in other places by.
|
||||
+ RatesTag
|
||||
RatesTag
|
||||
The rating tag described in the rates file.
|
||||
+ TimingTag
|
||||
TimingTag
|
||||
The timing tag described in the timing file
|
||||
Weight
|
||||
If multiple timings cab be applied to a call the one with the lower weight wins.
|
||||
|
||||
|
||||
Rates
|
||||
-----
|
||||
@@ -65,36 +68,34 @@ Rates
|
||||
+---------------------+-----------------+------------+-------+-------------+
|
||||
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this rate will be referenced in other places by.
|
||||
+ DestinationsTag
|
||||
DestinationsTag
|
||||
The destination tag witch these rates apply to.
|
||||
+ ConnectFee
|
||||
ConnectFee
|
||||
The price to be charged once at the beginning of the call to the specified destination.
|
||||
+ Price
|
||||
Price
|
||||
The price for the billing unit expressed in cents.
|
||||
+ BillingUnit
|
||||
BillingUnit
|
||||
The billing unit expressed in seconds
|
||||
|
||||
Timings
|
||||
-------
|
||||
|
||||
+-------------+--------+-----------+-----------+----------+--------+
|
||||
| Tag | Months | MonthDays | WeekDays | StartTime| Weight |
|
||||
+=============+========+===========+===========+==========+========+
|
||||
| WORKDAYS_00 | *all | *all | 1;2;3;4;5 | 00:00:00 | 10 |
|
||||
+-------------+--------+-----------+-----------+----------+--------+
|
||||
| WORKDAYS_18 | *all | *all | 1;2;3;4;5 | 18:00:00 | 10 |
|
||||
+-------------+--------+-----------+-----------+----------+--------+
|
||||
+-------------+--------+-----------+-----------+----------+
|
||||
| Tag | Months | MonthDays | WeekDays | StartTime|
|
||||
+=============+========+===========+===========+==========+
|
||||
| WORKDAYS_00 | *all | *all | 1;2;3;4;5 | 00:00:00 |
|
||||
+-------------+--------+-----------+-----------+----------+
|
||||
| WORKDAYS_18 | *all | *all | 1;2;3;4;5 | 18:00:00 |
|
||||
+-------------+--------+-----------+-----------+----------+
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this timing will be referenced in other places by.
|
||||
+ Months
|
||||
+ MonthDays
|
||||
+ WeekDays
|
||||
+ StartTime
|
||||
+ Weight
|
||||
If multiple timings cab be applied to a call the one with the lower weight wins.
|
||||
Months
|
||||
MonthDays
|
||||
WeekDays
|
||||
StartTime
|
||||
|
||||
Destinations
|
||||
------------
|
||||
@@ -109,9 +110,9 @@ The destinations are binding together various prefixes / caller ids to define a
|
||||
| GERMANY_O2 | 49176 |
|
||||
+------------+-------+
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this destination will be referenced in other places by.
|
||||
+ Prefix
|
||||
Prefix
|
||||
The prefix or caller id to be added to the specified destination.
|
||||
|
||||
Account actions
|
||||
@@ -125,11 +126,11 @@ Account actions
|
||||
| CUSTOMER_1 | dan | OUT | STANDARD_ABO | STANDARD_TRIGGER |
|
||||
+------------+---------+-----------+------------------+------------------+
|
||||
|
||||
+ Tenant
|
||||
+ Account
|
||||
+ Direction
|
||||
+ ActionTimingsTag
|
||||
+ ActionTriggersTag
|
||||
Tenant
|
||||
Account
|
||||
Direction
|
||||
ActionTimingsTag
|
||||
ActionTriggersTag
|
||||
|
||||
Action triggers
|
||||
---------------
|
||||
@@ -142,13 +143,13 @@ Action triggers
|
||||
| STANDARD_TRIGGER | SMS | 30 | *all |SOME_2 | 10 |
|
||||
+------------------+------------+----------------+----------------+------------+--------+
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this action trigger will be referenced in other places by.
|
||||
+ BalanceTag
|
||||
+ ThresholdValue
|
||||
+ DestinationTag
|
||||
+ ActionsTag
|
||||
+ Weight
|
||||
BalanceTag
|
||||
ThresholdValue
|
||||
DestinationTag
|
||||
ActionsTag
|
||||
Weight
|
||||
|
||||
Action timings
|
||||
--------------
|
||||
@@ -161,11 +162,11 @@ Action timings
|
||||
| STANDARD_ABO | SOME | WEEKLY_SAME_TIME | 10 |
|
||||
+--------------+------------+------------------+--------+
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this action timing will be referenced in other places by.
|
||||
+ ActionsTag
|
||||
+ TimingTag
|
||||
+ Weight
|
||||
ActionsTag
|
||||
TimingTag
|
||||
Weight
|
||||
|
||||
Actions
|
||||
-------
|
||||
@@ -178,13 +179,13 @@ Actions
|
||||
| SOME_1 | DEBIT | MINUTES | 10 | GERMANY_O2 | PERCENT | 25 | 10 | 10 |
|
||||
+--------+-------------+------------+-------+----------------+-----------+------------+---------------+--------+
|
||||
|
||||
+ Tag
|
||||
Tag
|
||||
A string by witch this action will be referenced in other places by.
|
||||
+ Action
|
||||
+ BalanceTag
|
||||
+ Units
|
||||
+ DestinationTag
|
||||
+ PriceType
|
||||
+ PriceValue
|
||||
+ MinutesWeight
|
||||
+ Weight
|
||||
Action
|
||||
BalanceTag
|
||||
Units
|
||||
DestinationTag
|
||||
PriceType
|
||||
PriceValue
|
||||
MinutesWeight
|
||||
Weight
|
||||
|
||||
@@ -2,7 +2,7 @@ Introduction
|
||||
============
|
||||
CGRateS is a very fast and easy scalable rating engine targeted especially for telecom providers.
|
||||
|
||||
It is written in go (http://golang.net) and accessible from any language via JSON RPC. The code is well documented (go doc compliant API docs) and heavily tested.
|
||||
It is written in go (http://golang.org) and accessible from any language via JSON RPC. The code is well documented (go doc compliant API docs) and heavily tested.
|
||||
|
||||
After testing various databases like Kyoto_ cabinet, Redis_ or Mongodb_, the project focused on Redis as it delivers the best trade-off between speed, configuration and scalability. However connection to any database can be easily integrated by writing a simple adapter.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user