fixed error when fetching unused types of fuel
This commit is contained in:
parent
a92d119b9d
commit
af4e13adfa
17
functions.go
17
functions.go
@ -110,17 +110,22 @@ 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)
|
||||||
|
|
||||||
for _, i := range list.Attr {
|
if list != nil {
|
||||||
if i.Name.Local == "valeur" {
|
for _, i := range list.Attr {
|
||||||
var val float64
|
if i.Name.Local == "valeur" {
|
||||||
if s, err := strconv.ParseFloat(i.Value, 64); err == nil {
|
var val float64
|
||||||
val = s
|
if s, err := strconv.ParseFloat(i.Value, 64); err == nil {
|
||||||
|
val = s
|
||||||
|
}
|
||||||
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user