fix(pkg/logfile): description for exported functions
This commit is contained in:
parent
fbb062d091
commit
314f5a41e5
@ -12,9 +12,6 @@ import (
|
||||
"github.com/volker-raschek/flucky/pkg/types"
|
||||
)
|
||||
|
||||
// Define the entry size for each logfile
|
||||
var templeratureSplitBy = 10000
|
||||
|
||||
// CompressTemperature compresses the temperatures from an array. It is checked
|
||||
// whether the measured temperature of a value corresponds to that of the
|
||||
// predecessor. If this is the case, the current value is discarded and the
|
||||
@ -54,6 +51,7 @@ func CompressTemperature(temperatures []*types.Temperature) []*types.Temperature
|
||||
return compressedTemperatures
|
||||
}
|
||||
|
||||
// ReadTemperatures from a file and returns an array with temperatures
|
||||
func ReadTemperatures(temperatureLogfile string) ([]*types.Temperature, error) {
|
||||
|
||||
if _, err := os.Stat(temperatureLogfile); os.IsNotExist(err) {
|
||||
@ -76,6 +74,8 @@ func ReadTemperatures(temperatureLogfile string) ([]*types.Temperature, error) {
|
||||
return temperatures, nil
|
||||
}
|
||||
|
||||
// ReadTemperaturesCustom from a custom reader and returns an array with
|
||||
// temperatures
|
||||
func ReadTemperaturesCustom(r io.Reader) ([]*types.Temperature, error) {
|
||||
|
||||
temperatures := make([]*types.Temperature, 0)
|
||||
@ -89,7 +89,9 @@ func ReadTemperaturesCustom(r io.Reader) ([]*types.Temperature, error) {
|
||||
return temperatures, nil
|
||||
}
|
||||
|
||||
func SplittTemperatures(temperatures []*types.Temperature) [][]*types.Temperature {
|
||||
// SplittTemperatures into multiple arrays. The Size can be defined by
|
||||
// temperatureSplitBy parameter.
|
||||
func SplittTemperatures(temperatures []*types.Temperature, templeratureSplitBy int) [][]*types.Temperature {
|
||||
splittedTemperatures := make([][]*types.Temperature, 0)
|
||||
newTemperatures := make([]*types.Temperature, 0)
|
||||
for _, temperature := range temperatures {
|
||||
@ -103,12 +105,15 @@ func SplittTemperatures(temperatures []*types.Temperature) [][]*types.Temperatur
|
||||
return splittedTemperatures
|
||||
}
|
||||
|
||||
// SortTemperatures by TemperatureFromDate
|
||||
func SortTemperatures(temperatures []*types.Temperature) {
|
||||
sort.SliceStable(temperatures, func(i int, j int) bool {
|
||||
return temperatures[i].TemperatureFromDate.Before(temperatures[j].TemperatureFromDate)
|
||||
})
|
||||
}
|
||||
|
||||
// WriteTemperatures encode temperatures into json and write it into a file.
|
||||
// Compression can be enabled over a bolean parameter
|
||||
func WriteTemperatures(temperatures []*types.Temperature, temperatureLogfile string, compression bool) error {
|
||||
|
||||
allTemperatures := make([]*types.Temperature, 0)
|
||||
@ -156,6 +161,8 @@ func WriteTemperatures(temperatures []*types.Temperature, temperatureLogfile str
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteTemperaturesCustom encode temperatures into json and write it into
|
||||
// custom writer. Compression can be enabled over a bolean parameter
|
||||
func WriteTemperaturesCustom(temperatures []*types.Temperature, w io.Writer, compression bool) error {
|
||||
|
||||
if compression {
|
||||
|
Loading…
Reference in New Issue
Block a user