mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 00:28:44 +05:00
extended timespan compression
This commit is contained in:
@@ -204,6 +204,8 @@ func (s *Session) Refund(lastCC *engine.CallCost, hangupTime time.Time) error {
|
||||
TOR: lastCC.TOR,
|
||||
Increments: refundIncrements,
|
||||
}
|
||||
cd.Increments.Compress()
|
||||
utils.Logger.Info(fmt.Sprintf("Refunding duration %v with cd: %+v", refundDuration, cd))
|
||||
var response float64
|
||||
err := s.sessionManager.Rater().RefundIncrements(cd, &response)
|
||||
if err != nil {
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestSessionRefund(t *testing.T) {
|
||||
cc := &engine.CallCost{Timespans: engine.TimeSpans{ts}}
|
||||
hangupTime := time.Date(2015, 6, 10, 14, 7, 20, 0, time.UTC)
|
||||
s.Refund(cc, hangupTime)
|
||||
if len(mc.refundCd.Increments) != 10 || len(cc.Timespans) != 1 || cc.Timespans[0].TimeEnd != hangupTime {
|
||||
if len(mc.refundCd.Increments) != 1 || mc.refundCd.Increments[0].GetCompressFactor() != 10 || len(cc.Timespans) != 1 || cc.Timespans[0].TimeEnd != hangupTime {
|
||||
t.Errorf("Error refunding: %+v, %+v", mc.refundCd.Increments, cc.Timespans[0])
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func TestSessionRefundAll(t *testing.T) {
|
||||
cc := &engine.CallCost{Timespans: engine.TimeSpans{ts}}
|
||||
hangupTime := time.Date(2015, 6, 10, 14, 7, 0, 0, time.UTC)
|
||||
s.Refund(cc, hangupTime)
|
||||
if len(mc.refundCd.Increments) != 30 || len(cc.Timespans) != 0 {
|
||||
if len(mc.refundCd.Increments) != 1 || mc.refundCd.Increments[0].GetCompressFactor() != 30 || len(cc.Timespans) != 0 {
|
||||
t.Errorf("Error refunding: %+v, %+v", len(mc.refundCd.Increments), cc.Timespans)
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ func TestSessionRefundManyAll(t *testing.T) {
|
||||
cc := &engine.CallCost{Timespans: engine.TimeSpans{ts1, ts2}}
|
||||
hangupTime := time.Date(2015, 6, 10, 14, 07, 0, 0, time.UTC)
|
||||
s.Refund(cc, hangupTime)
|
||||
if len(mc.refundCd.Increments) != 60 || len(cc.Timespans) != 0 {
|
||||
if len(mc.refundCd.Increments) != 1 || mc.refundCd.Increments[0].GetCompressFactor() != 60 || len(cc.Timespans) != 0 {
|
||||
t.Errorf("Error refunding: %+v, %+v", len(mc.refundCd.Increments), cc.Timespans)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,8 @@ func (self *SMGSession) refund(refundDuration time.Duration) error {
|
||||
TOR: lastCC.TOR,
|
||||
Increments: refundIncrements,
|
||||
}
|
||||
cd.Increments.Compress()
|
||||
utils.Logger.Info(fmt.Sprintf("Refunding duration %v with cd: %+v", refundDuration, cd))
|
||||
var response float64
|
||||
err := self.rater.RefundIncrements(cd, &response)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user