fixed error when fetching unused types of fuel

This commit is contained in:
Paul 2019-06-26 02:23:57 +02:00
parent a92d119b9d
commit af4e13adfa

View File

@ -110,9 +110,11 @@ func GetPrices(prices **[]Price, fpc *FuelPricesConfig, output *[]byte) error {
for _, station := range fpc.Pos { for _, station := range fpc.Pos {
for _, fuel := range fpc.Types { for _, fuel := range fpc.Types {
query := fmt.Sprintf(fpc.XPathBase, station, fuel) query := fmt.Sprintf(fpc.XPathBase, station, fuel)
list := xmlquery.FindOne(xml, query) list := xmlquery.FindOne(xml, query)
if list != nil {
for _, i := range list.Attr { for _, i := range list.Attr {
if i.Name.Local == "valeur" { if i.Name.Local == "valeur" {
var val float64 var val float64
@ -122,6 +124,9 @@ func GetPrices(prices **[]Price, fpc *FuelPricesConfig, output *[]byte) error {
pr = append(pr, Price{ID: station, Fuel: fuel, Amount: val}) pr = append(pr, Price{ID: station, Fuel: fuel, Amount: val})
} }
} }
} else {
log.Println(fmt.Sprintf("Fuel type not found for point of sale, skipping. Query : %s", query))
}
} }
} }
*prices = &pr *prices = &pr