log call cost method for cassandra

This commit is contained in:
Radu Ioan Fericean
2015-09-28 12:59:09 +03:00
parent 2740039dd0
commit c661a95f41

View File

@@ -1,7 +1,9 @@
package engine
import (
"encoding/json"
"fmt"
"time"
"github.com/cgrates/cgrates/utils"
"github.com/gocql/gocql"
@@ -42,7 +44,7 @@ func (cs *CassandraStorage) Flush(ignore string) (err error) {
func (cs *CassandraStorage) SetRatedCdr(*StoredCdr) error { return nil }
func (cs *CassandraStorage) LogCallCost(cgrid, source, runid string, cc *CallCost) error {
/*if cc == nil {
if cc == nil {
return nil
}
tss, err := json.Marshal(cc.Timespans)
@@ -50,7 +52,7 @@ func (cs *CassandraStorage) LogCallCost(cgrid, source, runid string, cc *CallCos
Logger.Err(fmt.Sprintf("Error marshalling timespans to json: %v", err))
return err
}
_, err = self.Db.Exec(fmt.Sprintf("INSERT INTO %s (cgrid,runid,tor,direction,tenant,category,account,subject,destination,cost,timespans,cost_source,created_at) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s',%f,'%s','%s','%s') ON DUPLICATE KEY UPDATE tor=values(tor),direction=values(direction),tenant=values(tenant),category=values(category),account=values(account),subject=values(subject),destination=values(destination),cost=values(cost),timespans=values(timespans),cost_source=values(cost_source),updated_at='%s'",
if err = cs.db.Query(fmt.Sprintf("INSERT INTO %s (cgrid,runid,tor,direction,tenant,category,account,subject,destination,cost,timespans,cost_source,created_at) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s',%f,'%s','%s','%s') tor=values(tor),direction=values(direction),tenant=values(tenant),category=values(category),account=values(account),subject=values(subject),destination=values(destination),cost=values(cost),timespans=values(timespans),cost_source=values(cost_source),updated_at='%s'",
utils.TBL_COST_DETAILS,
cgrid,
runid,
@@ -65,11 +67,10 @@ func (cs *CassandraStorage) LogCallCost(cgrid, source, runid string, cc *CallCos
tss,
source,
time.Now().Format(time.RFC3339),
time.Now().Format(time.RFC3339)))
if err != nil {
time.Now().Format(time.RFC3339))).Exec(); err != nil {
Logger.Err(fmt.Sprintf("failed to execute insert statement: %v", err))
return err
}*/
}
return nil
}
func (cs *CassandraStorage) GetCallCostLog(cgrid, source, runid string) (*CallCost, error) {