misc fixes
This commit is contained in:
parent
8bdad9cbd2
commit
26dbbc08e1
@ -20,11 +20,6 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
cr, err = coronafana.GetData(cfg)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
db, err := sqlx.Connect("mysql",
|
||||
fmt.Sprintf("%s:%s@tcp(%s)/%s",
|
||||
cfg.DbUsername,
|
||||
@ -35,28 +30,33 @@ func main() {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
_, err = db.Exec(cfg.DbSchemaGlobal)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
_, err = db.Exec(cfg.DbSchemaPays)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
cr, err = coronafana.GetData(cfg)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
err = cr.GetMaxDates(cfg, *db)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// Processes data for 'Global'
|
||||
_, err = db.Exec(cfg.DbSchemaGlobal)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
err = cr.InsertGlobalData(cfg, *db)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// Processes data for 'Pays'
|
||||
_, err = db.Exec(cfg.DbSchemaPays)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
err = cr.InsertPaysData(cfg, *db)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
|
@ -56,7 +56,7 @@ func (config *Config) GetConfig() (err error) {
|
||||
ON DUPLICATE KEY UPDATE date=:date,infection=:infection, deces=:deces, guerisons=:guerisons, tauxdeces=:tauxdeces, tauxguerison=:tauxguerison, tauxinfection=:tauxinfection;
|
||||
`
|
||||
|
||||
config.DbMaxDateGlobal = `SELECT max(date) FROM coronaglobaldata;`
|
||||
config.DbMaxDateGlobal = `SELECT IFNULL(MAX(date),"0001-01-01 00:00:00") FROM coronaglobaldata;`
|
||||
|
||||
config.DbSchemaPays = `
|
||||
CREATE TABLE IF NOT EXISTS coronapaysdata
|
||||
@ -79,7 +79,7 @@ func (config *Config) GetConfig() (err error) {
|
||||
VALUES (:date, :pays, :infection, :deces, :guerisons, :tauxdeces, :tauxguerison, :tauxinfection)
|
||||
ON DUPLICATE KEY UPDATE date=:date, pays=:pays,infection=:infection, deces=:deces, guerisons=:guerisons, tauxdeces=:tauxdeces, tauxguerison=:tauxguerison, tauxinfection=:tauxinfection;`
|
||||
|
||||
config.DbMaxDatePays = `SELECT max(date) FROM coronapaysdata;`
|
||||
config.DbMaxDatePays = `SELECT IFNULL(MAX(date),"0001-01-01 00:00:00") FROM coronapaysdata;`
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ func (cr *Coronafana) ReplacePaysQuotes() (err error) {
|
||||
for _, pdata := range cr.PaysData {
|
||||
pdata.Pays = strings.Replace(pdata.Pays, `'`, `\'`, -1)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user