update priority bug fixed

This commit is contained in:
Suraj 2016-02-06 01:37:45 +05:30
parent 58918d41af
commit 761ba4e33a
2 changed files with 8 additions and 4 deletions

View File

@ -89,7 +89,7 @@ func GetTasks(status, category string) (types.Context, error) {
if category != "" { if category != "" {
status = 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) rows, err = database.db.Query(getTasksql, category)
if err != nil { if err != nil {
log.Println("something went wrong while getting query") 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 //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) 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 return err
} }

View File

@ -96,7 +96,11 @@ func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) {
category := r.Form.Get("category") category := r.Form.Get("category")
title := r.Form.Get("title") title := r.Form.Get("title")
content := r.Form.Get("content") 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 { if err != nil {
message = "Error updating task" message = "Error updating task"
} else { } else {