From 16e815b57f5c2cabc3251ebb4043afa61dbd2454 Mon Sep 17 00:00:00 2001 From: Gerdriaan Mulder Date: Sat, 25 Jan 2020 14:29:55 +0100 Subject: [PATCH] Texts are fixed price, regardless of destination --- combine.go | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/combine.go b/combine.go index b8d7395..a37e95a 100644 --- a/combine.go +++ b/combine.go @@ -5,24 +5,11 @@ import ( ) func CombineTextCDRs(cdrLines []Line, prices []Price) ([]Text, error) { - // Preprocess the price list into a map of "destination" -> Price, filter out the Text destinations, and count how many Text CDRs we have - destinationToPriceLine := make(map[string]Price) numTextCDRs := 0 for _, l := range cdrLines { if l.Kind != TextLine { continue } - if _, ok := destinationToPriceLine[l.Destination]; !ok { - for _, p := range prices { - if p.Type != PriceText { - continue - } - if p.Destination == l.Destination { - destinationToPriceLine[l.Destination] = p - break - } - } - } numTextCDRs++ } @@ -36,8 +23,8 @@ func CombineTextCDRs(cdrLines []Line, prices []Price) ([]Text, error) { ret[i] = Text{ PricedLine{ Line: l, - Cost: destinationToPriceLine[l.Destination].BuyEach, - Price: destinationToPriceLine[l.Destination].SellEach, + Cost: TEXT_OUTGOING_BUY, + Price: TEXT_OUTGOING_SELL, }, } i++ @@ -59,10 +46,25 @@ func CombineDataCDRs(cdrLines []Line, prices []Price) ([]Data, error) { } func CombineCallCDRs(cdrLines []Line, prices []Price) ([]Call, error) { + // Preprocess the price list into a map of "destination" -> Price, filter out the Text destinations, and count how many Text CDRs we have + destinationToPriceLine := make(map[string]Price) + numCallCDRs := 0 for _, l := range cdrLines { if l.Kind != VoiceLine { continue } + if _, ok := destinationToPriceLine[l.Destination]; !ok { + for _, p := range prices { + if p.Type != PriceCall { + continue + } + if p.Destination == l.Destination { + destinationToPriceLine[l.Destination] = p + break + } + } + } + numCallCDRs++ } return nil, fmt.Errorf("not yet implemented") }