52 lines
2.0 KiB
Go
52 lines
2.0 KiB
Go
package meteo
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
)
|
|
|
|
type H map[string]any
|
|
|
|
type MeteoData struct {
|
|
Timestamp time.Time `csv:"fecha"`
|
|
Location string `csv:"ciudad"`
|
|
MaxTemp float32 `csv:"temperatura maxima"`
|
|
MinTemp float32 `csv:"temperatura minima"`
|
|
Rainfall float32 `csv:"precipitacion"`
|
|
Cloudiness int `csv:"nubosidad"`
|
|
}
|
|
|
|
type RejectedMeteoData struct {
|
|
RowValue string
|
|
Reason string
|
|
}
|
|
|
|
type FileStats struct {
|
|
BatchID int `json:"batch_id"`
|
|
RowsInserted int `json:"rows_inserted"`
|
|
RowsRejected int `json:"rows_rejected"`
|
|
ElapsedMS int `json:"elapsed_ms"`
|
|
FileChecksum string `json:"file_checksum"`
|
|
}
|
|
|
|
var (
|
|
ErrCannotParseFile = errors.New("cannot parse file")
|
|
ErrValidateRecord = errors.New("error validating record")
|
|
ErrRecordNotValid = errors.New("record not valid")
|
|
ErrReadingCSVHeader = errors.New("error reading CSV header")
|
|
ErrReadingCSVRow = errors.New("error reading CSV row")
|
|
ErrMissingOrInvalidDateField = errors.New("missing or invalid date field")
|
|
ErrMissingOrInvalidCityField = errors.New("missing or invalid city field")
|
|
ErrMissingOrInvalidMaxTemp = errors.New("missing or invalid max temp field")
|
|
ErrMissingOrInvalidMinTemp = errors.New("missing or invalid min temp field")
|
|
ErrMissingOrInvalidRainfall = errors.New("missing or invalid rainfall field")
|
|
ErrMissingOrInvalidCloudiness = errors.New("missing or invalid cloudiness field")
|
|
ErrMaxTempOutOfRange = errors.New("max temp out of range (must be <= 60°C)")
|
|
ErrMinTempOutOfRange = errors.New("min temp out of range (must be >= -20°C)")
|
|
ErrRainfallOutOfRange = errors.New("rainfall out of range (must be 0-500 mm)")
|
|
ErrCloudinessOutOfRange = errors.New("cloudiness out of range (must be 0-100%)")
|
|
ErrParsingForm = errors.New("error parsing form")
|
|
ErrRetrievingFile = errors.New("error retrieving file")
|
|
ErrReadingFile = errors.New("error reading file")
|
|
)
|