Tidy up (less verbosity), actual DB update for EDGEAPPS_LIST

This commit is contained in:
Paulo Truta
2021-02-17 13:34:53 +01:00
parent 2817628fef
commit 0bd61ccf75
3 changed files with 34 additions and 25 deletions
+15 -16
View File
@@ -141,12 +141,12 @@ func ExecuteSchedules(tick int) {
if tick == 1 {
// Executing on startup (first tick). Schedules run before tasks in the SystemIterator
taskGetEdgeApps()
log.Println(taskGetEdgeApps())
}
if tick%30 == 0 {
// Executing every 30 ticks
taskGetEdgeApps()
log.Println(taskGetEdgeApps())
}
@@ -183,28 +183,27 @@ func taskGetEdgeApps() string {
edgeApps := edgeapps.GetEdgeApps()
edgeAppsJSON, _ := json.Marshal(edgeApps)
log.Println(string(edgeAppsJSON))
// db, err := sql.Open("mysql", utils.GetMySQLDbConnectionDetails())
db, err := sql.Open("mysql", utils.GetMySQLDbConnectionDetails())
// if err != nil {
// panic(err.Error())
// }
if err != nil {
panic(err.Error())
}
// defer db.Close()
defer db.Close()
// statusUpdate, err := db.Query("UPDATE options SET value = '" + + "' WHERE name = 'EDGEAPPS_LIST'")
statusUpdate, err := db.Query("REPLACE into options (name, value) VALUES ('EDGEAPPS_LIST','" + string(edgeAppsJSON) + "');")
// if err != nil {
// panic(err.Error())
// }
if err != nil {
panic(err.Error())
}
// for statusUpdate.Next() {
for statusUpdate.Next() {
// }
}
return string(edgeAppsJSON)
// Saving information in the "options" table.
return "OK"
}
func taskStartEdgeApp() string {