mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
removed rate
This commit is contained in:
@@ -19,14 +19,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package cdrs
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/rater"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"strconv"
|
||||
"time"
|
||||
"fmt"
|
||||
"crypto/sha1"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -48,7 +47,6 @@ const (
|
||||
DURATION = "billsec"
|
||||
USERNAME = "user_name"
|
||||
FS_IP = "sip_local_network_addr"
|
||||
RATE = "rate"
|
||||
)
|
||||
|
||||
type FSCdr map[string]string
|
||||
@@ -72,8 +70,8 @@ func (fsCdr FSCdr) New(body []byte) (rater.CDR, error) {
|
||||
|
||||
func (fsCdr FSCdr) GetCgrId() string {
|
||||
hasher := sha1.New()
|
||||
hasher.Write([]byte( fsCdr[FS_IP] ))
|
||||
hasher.Write([]byte( fsCdr[UUID] ))
|
||||
hasher.Write([]byte(fsCdr[FS_IP]))
|
||||
hasher.Write([]byte(fsCdr[UUID]))
|
||||
return fmt.Sprintf("%x", hasher.Sum(nil))
|
||||
}
|
||||
func (fsCdr FSCdr) GetAccId() string {
|
||||
@@ -128,27 +126,14 @@ func (fsCdr FSCdr) GetStartTime() (t time.Time, err error) {
|
||||
t = time.Unix(0, st*1000)
|
||||
return
|
||||
}
|
||||
|
||||
func (fsCdr FSCdr) GetEndTime() (t time.Time, err error) {
|
||||
st, err := strconv.ParseInt(fsCdr[END_TIME], 0, 64)
|
||||
t = time.Unix(0, st*1000)
|
||||
return
|
||||
}
|
||||
|
||||
// Extracts duration as considered by the telecom switch
|
||||
func (fsCdr FSCdr) GetDuration() int64 {
|
||||
dur, _ := strconv.ParseInt(fsCdr[DURATION], 0, 64)
|
||||
return dur
|
||||
}
|
||||
|
||||
|
||||
func (fsCdr FSCdr) GetRate() (float64, error) {
|
||||
rate, ok := fsCdr[RATE]
|
||||
if !ok {
|
||||
return -1, errors.New("Not found")
|
||||
}
|
||||
return strconv.ParseFloat(rate, 64)
|
||||
}
|
||||
|
||||
func (fsCdr FSCdr) SetRate(rate float64) {
|
||||
fsCdr[RATE] = strconv.FormatFloat(rate, 'f', -1, 64)
|
||||
}
|
||||
|
||||
@@ -42,6 +42,4 @@ type CDR interface {
|
||||
GetDuration() int64
|
||||
GetFallbackSubj() string
|
||||
GetExtraParameters() string
|
||||
GetRate() (float64, error)
|
||||
SetRate(float64)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (mys *MySQLStorage) SetCdr(cdr CDR) (err error) {
|
||||
cdr.GetSubject(),
|
||||
cdr.GetDestination(),
|
||||
startTime,
|
||||
cdr.GetDuration(), //duration
|
||||
cdr.GetDuration(),
|
||||
))
|
||||
if err != nil {
|
||||
Logger.Err(fmt.Sprintf("failed to execute cdr insert statement: %v", err))
|
||||
|
||||
@@ -127,10 +127,6 @@ func (psl *PostgresStorage) SetCdr(cdr CDR) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
endTime, err := cdr.GetEndTime()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = psl.Db.Exec(fmt.Sprintf("INSERT INTO cdrs_primary VALUES ('%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', %v, %v, '%s')",
|
||||
cdr.GetCgrId(),
|
||||
cdr.GetAccId(),
|
||||
@@ -143,7 +139,7 @@ func (psl *PostgresStorage) SetCdr(cdr CDR) (err error) {
|
||||
cdr.GetSubject(),
|
||||
cdr.GetDestination(),
|
||||
startTime,
|
||||
endTime, //duration
|
||||
cdr.GetDuration(),
|
||||
))
|
||||
if err != nil {
|
||||
Logger.Err(fmt.Sprintf("failed to execute cdr insert statement: %v", err))
|
||||
|
||||
Reference in New Issue
Block a user