updated fuelprices
This commit is contained in:
parent
d591cdcb76
commit
7e0328028b
@ -10,40 +10,6 @@ import (
|
||||
client "github.com/influxdata/influxdb1-client/v2"
|
||||
)
|
||||
|
||||
// Srcfile source file
|
||||
type Srcfile struct {
|
||||
Filename string
|
||||
Filepath string
|
||||
Content []byte
|
||||
}
|
||||
|
||||
// Outfile is the output XML file
|
||||
type Outfile struct {
|
||||
Content []byte
|
||||
}
|
||||
|
||||
// FuelPricesConfig is the main configuration
|
||||
type FuelPricesConfig struct {
|
||||
RemoteURL string
|
||||
RemoteFilename string
|
||||
XPathBase string
|
||||
Pos []string
|
||||
Types []string
|
||||
TmpDir string
|
||||
InfluxHost string
|
||||
InfluxPort int
|
||||
InfluxUser string
|
||||
InfluxPass string
|
||||
InfluxDB string
|
||||
}
|
||||
|
||||
// Price contains price of points of sale
|
||||
type Price struct {
|
||||
ID string
|
||||
Fuel string
|
||||
Amount float64
|
||||
}
|
||||
|
||||
var szip Srcfile
|
||||
var sxml Srcfile
|
||||
var ofile Outfile
|
||||
@ -88,7 +54,7 @@ func main() {
|
||||
fields := map[string]interface{}{"value": p.Amount}
|
||||
|
||||
point, _ := client.NewPoint(
|
||||
"fuel_price",
|
||||
fpc.InfluxTable,
|
||||
tags,
|
||||
fields,
|
||||
now,
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/antchfx/xmlquery"
|
||||
"gopkg.in/ini.v1"
|
||||
@ -43,9 +42,10 @@ func GetConfig(configfile string, fuelpricesconfig *FuelPricesConfig) error {
|
||||
HandleError(err)
|
||||
|
||||
fpc.InfluxDB = fuelpricesSection.Key("influx_db").String()
|
||||
fpc.InfluxTable = fuelpricesSection.Key("influx_table").String()
|
||||
|
||||
fpc.Pos = strings.Split(fuelpricesSection.Key("pos").String(), ",")
|
||||
fpc.Types = strings.Split(fuelpricesSection.Key("types").String(), ",")
|
||||
fpc.Pos = fuelpricesSection.Key("pos").Strings(",")
|
||||
fpc.Types = fuelpricesSection.Key("types").Strings(",")
|
||||
|
||||
*fuelpricesconfig = fpc
|
||||
|
||||
@ -136,7 +136,6 @@ func HandleFatalError(err error) {
|
||||
|
||||
// Usage displays possible arguments
|
||||
func Usage() {
|
||||
fmt.Fprintf(os.Stderr, "Usage: fuelprices [configfile]\n")
|
||||
flag.PrintDefaults()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
36
types.go
Normal file
36
types.go
Normal file
@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
// Srcfile source file
|
||||
type Srcfile struct {
|
||||
Filename string
|
||||
Filepath string
|
||||
Content []byte
|
||||
}
|
||||
|
||||
// Outfile is the output XML file
|
||||
type Outfile struct {
|
||||
Content []byte
|
||||
}
|
||||
|
||||
// FuelPricesConfig is the main configuration
|
||||
type FuelPricesConfig struct {
|
||||
RemoteURL string
|
||||
RemoteFilename string
|
||||
XPathBase string
|
||||
Pos []string
|
||||
Types []string
|
||||
TmpDir string
|
||||
InfluxHost string
|
||||
InfluxPort int
|
||||
InfluxUser string
|
||||
InfluxPass string
|
||||
InfluxDB string
|
||||
InfluxTable string
|
||||
}
|
||||
|
||||
// Price contains price of points of sale
|
||||
type Price struct {
|
||||
ID string
|
||||
Fuel string
|
||||
Amount float64
|
||||
}
|
Loading…
Reference in New Issue
Block a user