diff --git a/db/tasks.go b/db/tasks.go index ad613da..6ee9250 100644 --- a/db/tasks.go +++ b/db/tasks.go @@ -89,7 +89,7 @@ func GetTasks(status, category string) (types.Context, error) { if category != "" { status = category - getTasksql = "select t.id, title, content, created_date, priority from task t, category c where c.id = t.cat_id and name = ?" + getTasksql = "select t.id, title, content, created_date, priority from task t, category c where c.id = t.cat_id and name = ? and is_deleted!='Y' order by priority desc, created_date asc, finish_date asc" rows, err = database.db.Query(getTasksql, category) if err != nil { log.Println("something went wrong while getting query") @@ -202,9 +202,9 @@ func GetCategoryIdByName(category string) int { } //UpdateTask is used to update the tasks in the database -func UpdateTask(id int, title, content, category string) error { +func UpdateTask(id int, title, content, category string, priority int) error { categoryID := GetCategoryIdByName(category) - err := taskQuery("update task set title=?, content=?, cat_id=? where id=?", title, content, categoryID, id) + err := taskQuery("update task set title=?, content=?, cat_id=?, priority = ? where id=?", title, content, categoryID, priority, id) return err } diff --git a/views/otherViews.go b/views/otherViews.go index 0413838..aaae3c9 100644 --- a/views/otherViews.go +++ b/views/otherViews.go @@ -96,7 +96,11 @@ func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) { category := r.Form.Get("category") title := r.Form.Get("title") content := r.Form.Get("content") - err = db.UpdateTask(id, title, content, category) + priority, err := strconv.Atoi(r.Form.Get("priority")) + if err != nil { + log.Println(err) + } + err = db.UpdateTask(id, title, content, category, priority) if err != nil { message = "Error updating task" } else {