Browse Source

Add check for all required data

master
Riyyi 4 months ago
parent
commit
3e8d495bea
  1. 4
      src/api.go
  2. 2
      src/process.go

4
src/api.go

@ -24,6 +24,10 @@ type api struct {}
func (api) CallApi(date string, from_time string, to_time string, item_id string, description string) error {
if item_id == "break" || item_id == "lunch" || item_id == "pauze" { return nil }
if date == "" || from_time == "" || to_time == "" || item_id == "" {
return fmt.Error("incomplete log entry: %s, %s-%s, %s, %s", date, from_time, to_time, item_id, description)
}
time1, err := time.Parse("15:04", from_time)
if err != nil { return fmt.Errorf("error parsing from_time: %s", err) }

2
src/process.go

@ -84,7 +84,7 @@ func (self *Process) parseTask(line string, line_number int) error {
}
// Call API for the previous task
if date.last_time != "" && date.last_item_id != "" && date.last_description != "" {
if date.last_time != "" && date.last_item_id != "" {
err = Api.CallApi(data[0], date.last_time, data[1], date.last_item_id, date.last_description)
}

Loading…
Cancel
Save