mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-16 05:39:54 +05:00
small fixses
This commit is contained in:
@@ -19,10 +19,8 @@ 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"
|
||||
@@ -70,10 +68,7 @@ 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]))
|
||||
return fmt.Sprintf("%x", hasher.Sum(nil))
|
||||
return utils.FSCgrId(fsCdr[UUID])
|
||||
}
|
||||
func (fsCdr FSCdr) GetAccId() string {
|
||||
return fsCdr[UUID]
|
||||
|
||||
@@ -218,6 +218,7 @@ func (m *Mediator) getCostsFromRater(record []string, runIdx int) (cc *rater.Cal
|
||||
if err != nil {
|
||||
m.loggerDb.LogError(record[m.uuidIndexs[runIdx]], rater.MEDIATOR_SOURCE, err.Error())
|
||||
} else {
|
||||
// If the mediator calculated a price it will write it to logdb
|
||||
m.loggerDb.LogCallCost(record[m.uuidIndexs[runIdx]], rater.MEDIATOR_SOURCE, cc)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -18,6 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Returns first non empty string out of vals. Useful to extract defaults
|
||||
func FirstNonEmpty(vals ...string) string {
|
||||
for _, val := range vals {
|
||||
@@ -27,3 +32,9 @@ func FirstNonEmpty(vals ...string) string {
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func FSCgrId(uuid string) string {
|
||||
hasher := sha1.New()
|
||||
hasher.Write([]byte(uuid))
|
||||
return fmt.Sprintf("%x", hasher.Sum(nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user