feat(cmd/temperature/compress): new subcommand to compress logfiles
This commit is contained in:
parent
bbcccd7479
commit
6707dabdf1
35
cmd/temperature/compression.go
Normal file
35
cmd/temperature/compression.go
Normal file
@ -0,0 +1,35 @@
|
||||
package temperature
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/go-flucky/flucky/pkg/logfile"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var compressTemperatureCmd = &cobra.Command{
|
||||
Use: "compress",
|
||||
Short: "Compress temperature logfiles",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Example: `flucky temperature compress /var/log/flucky/temperature.json
|
||||
flucky temperature compress /var/log/flucky/temperature.xml`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
temperatureLogfile := logfile.New(args[0])
|
||||
temperatures, err := temperatureLogfile.ReadTemperatures()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
temperatures = logfile.CompressTemperature(temperatures)
|
||||
|
||||
err = temperatureLogfile.WriteTemperatures(temperatures)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
temperatureCmd.AddCommand(compressTemperatureCmd)
|
||||
}
|
@ -7,9 +7,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var logfileInput string
|
||||
var logfileOutput string
|
||||
|
||||
var convertTemperatureCmd = &cobra.Command{
|
||||
Use: "convert",
|
||||
Short: "Convert temperature logfiles into other markup language",
|
||||
|
@ -1,11 +1,11 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-10-01T00:00:00.000000000+02:00",
|
||||
"temperature_till_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"update_date": "2019-10-01T00:00:00.000000000+02:00"
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-10-01T00:00:00+02:00",
|
||||
"temperature_till_date": "2019-05-01T00:00:00+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-05-01T00:00:00+02:00",
|
||||
"update_date": "2019-10-01T00:00:00+02:00"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -1,11 +1,11 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00.000000000+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-10-01T00:00:00.000000000+02:00",
|
||||
"update_date": "2019-05-01T00:00:00.000000000+02:00"
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-05-01T00:00:00+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-10-01T00:00:00+02:00",
|
||||
"update_date": "2019-05-01T00:00:00+02:00"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -1,11 +1,11 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00.000000000+02:00",
|
||||
"sensor_id": "",
|
||||
"creation_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"update_date": "2019-10-01T00:00:00.000000000+02:00"
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-05-01T00:00:00+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00+02:00",
|
||||
"sensor_id": "",
|
||||
"creation_date": "2019-05-01T00:00:00+02:00",
|
||||
"update_date": "2019-10-01T00:00:00+02:00"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -1,10 +1,11 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_from_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00.000000000+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"update_date": "2019-10-01T00:00:00.000000000+02:00"
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "0",
|
||||
"temperature_from_date": "2019-05-01T00:00:00+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-05-01T00:00:00+02:00",
|
||||
"update_date": "2019-10-01T00:00:00+02:00"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -1,11 +1,11 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00.000000000+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-05-01T00:00:00.000000000+02:00",
|
||||
"update_date": "2019-10-01T00:00:00.000000000+02:00"
|
||||
"temperature_id": "",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-05-01T00:00:00+02:00",
|
||||
"temperature_till_date": "2019-10-01T00:00:00+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-05-01T00:00:00+02:00",
|
||||
"update_date": "2019-10-01T00:00:00+02:00"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -1,20 +1,20 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.504051541+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:18:07.384104493+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": "2019-06-14T21:18:07.46587076+02:00"
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.504051541+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:18:07.384104493+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": "2019-06-14T21:18:07.46587076+02:00"
|
||||
},
|
||||
{
|
||||
"temperature_id": "5f119ba3-bcea-4c3b-aabb-0406ea70f7e1",
|
||||
"temperature_value": "24.375",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.583856443+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:18:07.463893776+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": "2019-06-14T21:18:07.46587701+02:00"
|
||||
"temperature_id": "5f119ba3-bcea-4c3b-aabb-0406ea70f7e1",
|
||||
"temperature_value": "24.375",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.583856443+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:18:07.463893776+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": "2019-06-14T21:18:07.46587701+02:00"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
@ -1,20 +1,20 @@
|
||||
[
|
||||
{
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.504051541+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:18:07.384104493+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": "2019-06-14T21:18:07.46587076+02:00"
|
||||
"temperature_id": "a469503b-fc16-4e72-8d29-7eeee08ba957",
|
||||
"temperature_value": "24.562",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.504051541+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:18:07.384104493+02:00",
|
||||
"sensor_id": "84eac248-6927-4db6-b6f9-7891ce2d301e",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": "2019-06-14T21:18:07.46587076+02:00"
|
||||
},
|
||||
{
|
||||
"temperature_id": "5f119ba3-bcea-4c3b-aabb-0406ea70f7e1",
|
||||
"temperature_value": "24.375",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.583856443+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:15:28.583856443+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": null
|
||||
"temperature_id": "5f119ba3-bcea-4c3b-aabb-0406ea70f7e1",
|
||||
"temperature_value": "24.375",
|
||||
"temperature_from_date": "2019-06-14T21:15:28.583856443+02:00",
|
||||
"temperature_till_date": "2019-06-14T21:15:28.583856443+02:00",
|
||||
"sensor_id": "efcd755e-82d1-4789-a50b-355b8735b8d8",
|
||||
"creation_date": "2019-06-14T21:18:07.465885864+02:00",
|
||||
"update_date": null
|
||||
}
|
||||
]
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user