Browse Source

Texts are fixed price, regardless of destination

master
Gerdriaan Mulder 6 years ago
parent
commit
16e815b57f
  1. 32
      combine.go

32
combine.go

@ -5,24 +5,11 @@ import (
) )
func CombineTextCDRs(cdrLines []Line, prices []Price) ([]Text, error) { 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 numTextCDRs := 0
for _, l := range cdrLines { for _, l := range cdrLines {
if l.Kind != TextLine { if l.Kind != TextLine {
continue 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++ numTextCDRs++
} }
@ -36,8 +23,8 @@ func CombineTextCDRs(cdrLines []Line, prices []Price) ([]Text, error) {
ret[i] = Text{ ret[i] = Text{
PricedLine{ PricedLine{
Line: l, Line: l,
Cost: destinationToPriceLine[l.Destination].BuyEach, Cost: TEXT_OUTGOING_BUY,
Price: destinationToPriceLine[l.Destination].SellEach, Price: TEXT_OUTGOING_SELL,
}, },
} }
i++ i++
@ -59,10 +46,25 @@ func CombineDataCDRs(cdrLines []Line, prices []Price) ([]Data, error) {
} }
func CombineCallCDRs(cdrLines []Line, prices []Price) ([]Call, 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 { for _, l := range cdrLines {
if l.Kind != VoiceLine { if l.Kind != VoiceLine {
continue 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") return nil, fmt.Errorf("not yet implemented")
} }

Loading…
Cancel
Save