Use const for task status (#18)
parent
9339e6cf09
commit
7430f0c8ce
|
@ -60,6 +60,11 @@ type taskDisableOnlineArgs struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STATUS_CREATED int = 0
|
||||||
|
const STATUS_EXECUTING int = 1
|
||||||
|
const STATUS_FINISHED int = 2
|
||||||
|
const STATUS_ERROR int = 3
|
||||||
|
|
||||||
// GetNextTask : Performs a MySQL query over the device's Edgebox API
|
// GetNextTask : Performs a MySQL query over the device's Edgebox API
|
||||||
func GetNextTask() Task {
|
func GetNextTask() Task {
|
||||||
|
|
||||||
|
@ -112,7 +117,7 @@ func ExecuteTask(task Task) Task {
|
||||||
|
|
||||||
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
formatedDatetime := utils.GetSQLiteFormattedDateTime(time.Now())
|
||||||
|
|
||||||
_, err = statement.Exec(1, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement
|
_, err = statement.Exec(STATUS_EXECUTING, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
@ -221,13 +226,13 @@ func ExecuteTask(task Task) Task {
|
||||||
formatedDatetime = utils.GetSQLiteFormattedDateTime(time.Now())
|
formatedDatetime = utils.GetSQLiteFormattedDateTime(time.Now())
|
||||||
|
|
||||||
if task.Result.Valid {
|
if task.Result.Valid {
|
||||||
_, err = statement.Exec(2, task.Result.String, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with result info
|
_, err = statement.Exec(STATUS_FINISHED, task.Result.String, formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with result info
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_, err = statement.Exec(3, "Error", formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with Error info
|
_, err = statement.Exec(STATUS_ERROR, "Error", formatedDatetime, strconv.Itoa(task.ID)) // Execute SQL Statement with Error info
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue