Skip to content

Commit

Permalink
No、市区町村名、公表_年月日が空欄や不正な値の場合はその行で処理を停止するように
Browse files Browse the repository at this point in the history
  • Loading branch information
miiton committed Apr 14, 2020
1 parent 9da5153 commit be422d6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions model/patients.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Patient struct {
}

func FetchPatients(svc *sheets.Service, spreadsheetID string) (*Patients, error) {
var err error
sheetRange := os.Getenv("COVID19_JSON2CSV_SHEET_RANGE_PATIENTS")
call := svc.Spreadsheets.Values.Get(spreadsheetID, sheetRange)
values, err := call.Do()
Expand All @@ -39,17 +40,20 @@ func FetchPatients(svc *sheets.Service, spreadsheetID string) (*Patients, error)
p.No, err = strconv.Atoi(val)
if err != nil {
log.Println(err)
return nil, err
break
}
}
if val, ok := v[3].(string); ok {
if val == "" {
break
}
p.Residence = val
}
if val, ok := v[4].(string); ok {
p.AnnouncementDate, err = time.Parse("2006-01-02", val)
if err != nil {
log.Println(err)
return nil, err
break
}
}
if val, ok := v[7].(string); ok {
Expand All @@ -60,7 +64,7 @@ func FetchPatients(svc *sheets.Service, spreadsheetID string) (*Patients, error)
}
ps.Data = append(ps.Data, p)
}
return &ps, nil
return &ps, err
}

func setSummaryData(cur time.Time, kv map[string]int) int {
Expand Down

0 comments on commit be422d6

Please sign in to comment.