bug fix, show tasks with null categories in main feed

This commit is contained in:
Suraj Patil 2016-05-22 15:10:40 +05:30
parent 0895618b67
commit f030c0d6a1
1 changed files with 5 additions and 4 deletions

View File

@ -85,7 +85,7 @@ func GetTasks(username, status, category string) (types.Context, error) {
return context, err return context, err
} }
basicSQL := "select t.id, title, content, created_date, priority, c.name from task t, category c, status s, user u where u.username=? and s.id=t.task_status_id and c.id=t.cat_id and u.id=t.user_id" basicSQL := "select t.id, title, content, created_date, priority, case when c.name is null then 'NA' else c.name end from task t, status s, user u left outer join category c on c.id=t.cat_id where u.username=? and s.id=t.task_status_id and u.id=t.user_id"
if category == "" { if category == "" {
switch status { switch status {
case "pending": case "pending":
@ -96,8 +96,9 @@ func GetTasks(username, status, category string) (types.Context, error) {
getTaskSQL = basicSQL + " and s.status='COMPLETE'" getTaskSQL = basicSQL + " and s.status='COMPLETE'"
} }
basicSQL += " order by priority desc, created_date asc" getTaskSQL += " order by t.created_date asc"
rows = database.query(getTaskSQL, username)
rows = database.query(getTaskSQL, username, username)
} else { } else {
status = category status = category
//This is a special case for showing tasks with null categories, we do a union query //This is a special case for showing tasks with null categories, we do a union query
@ -208,7 +209,7 @@ func AddTask(title, content, category string, taskPriority int, username string)
log.Println("AddTask: started function") log.Println("AddTask: started function")
var err error var err error
userID, err := GetUserID(username) userID, err := GetUserID(username)
if err != nil { if err != nil && (title != "" || content != "") {
return err return err
} }