From de6228f985de00d3a0f0330c7021d41520c7eb55 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Fri, 17 Apr 2020 13:17:15 +0200 Subject: [PATCH] updated max interval to 3 days --- src/config/main.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/config/main.go b/src/config/main.go index 525a72c..cd9c5a7 100644 --- a/src/config/main.go +++ b/src/config/main.go @@ -27,7 +27,8 @@ func (config *Config) GetConfig() (err error) { DbUsername: "username", DbPassword: "password", DbTable: "corona", - CoronaURL: "https://coronavirus.politologue.com/data/coronavirus/coronacsv.aspx?format=json"} + CoronaURL: "https://coronavirus.politologue.com/data/coronavirus/coronacsv.aspx?format=json", + } err = cfg.Section("coronafana").MapTo(config) if err != nil { @@ -47,8 +48,9 @@ func (config *Config) GetConfig() (err error) { tauxinfection float(10) DEFAULT NULL, PRIMARY KEY (id), UNIQUE KEY date (date) USING BTREE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - ` + ) + ENGINE=InnoDB DEFAULT CHARSET=utf8; + ` config.DbInsertGlobal = ` INSERT INTO coronaglobaldata (date, infection, deces, guerisons, tauxdeces, tauxguerison, tauxinfection) @@ -56,7 +58,10 @@ 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 IFNULL(SUBDATE(MAX(date), INTERVAL 1 DAY), "0001-01-01 00:00:00") FROM coronaglobaldata;` + config.DbMaxDateGlobal = ` + SELECT IFNULL(SUBDATE(MAX(date), INTERVAL 3 DAY), "0001-01-01 00:00:00") + FROM coronaglobaldata; + ` config.DbSchemaPays = ` CREATE TABLE IF NOT EXISTS coronapaysdata @@ -72,14 +77,20 @@ func (config *Config) GetConfig() (err error) { tauxinfection float(10) DEFAULT NULL, PRIMARY KEY (id), UNIQUE KEY date (date,pays) USING BTREE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8;` + ) + ENGINE=InnoDB DEFAULT CHARSET=utf8; + ` config.DbInsertPays = ` INSERT INTO coronapaysdata (date, pays, infection, deces, guerisons, tauxdeces, tauxguerison, tauxinfection) 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;` + ON DUPLICATE KEY UPDATE date=:date, pays=:pays,infection=:infection, deces=:deces, guerisons=:guerisons, tauxdeces=:tauxdeces, tauxguerison=:tauxguerison, tauxinfection=:tauxinfection; + ` - config.DbMaxDatePays = `SELECT IFNULL(SUBDATE(MAX(date), INTERVAL 1 DAY), "0001-01-01 00:00:00") FROM coronapaysdata;` + config.DbMaxDatePays = ` + SELECT IFNULL(SUBDATE(MAX(date), INTERVAL 3 DAY), "0001-01-01 00:00:00") + FROM coronapaysdata; + ` return }