pending tasks shown in count of categories & in the list
This commit is contained in:
parent
8aef7693a8
commit
2ea4b1b364
|
@ -46,7 +46,7 @@ func GetFileName(token string) (string, error) {
|
|||
//GetCategories will return the list of categories to be
|
||||
//rendered in the template
|
||||
func GetCategories() []types.CategoryCount {
|
||||
stmt := "select c.name, count(*) from category c left outer join task t where c.id = t.cat_id group by name union select name, 0 from category where name not in (select distinct name from task t join category c on t.cat_id = c.id)"
|
||||
stmt := "select c.name, count(*) from category c left outer join task t where c.id = t.cat_id and t.is_deleted='N' and t.finish_date is null group by name union select name, 0 from category where name not in (select distinct name from task t join category c on t.cat_id = c.id)"
|
||||
rows := database.query(stmt)
|
||||
var categories []types.CategoryCount
|
||||
var category types.CategoryCount
|
||||
|
|
|
@ -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 = ? and is_deleted!='Y' order by priority desc, created_date asc, finish_date asc"
|
||||
getTasksql = "select t.id, title, content, created_date, priority from task t, category c where c.id = t.cat_id and name = ? and t.is_deleted!='Y' and t.finish_date is null 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")
|
||||
|
|
|
@ -48,6 +48,8 @@ func ShowAllTasksFunc(w http.ResponseWriter, r *http.Request) {
|
|||
func ShowTrashTaskFunc(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "GET" {
|
||||
context, err := db.GetTasks("deleted", "")
|
||||
categories := db.GetCategories()
|
||||
context.Categories = categories
|
||||
if err != nil {
|
||||
http.Redirect(w, r, "/trash", http.StatusInternalServerError)
|
||||
}
|
||||
|
@ -66,6 +68,8 @@ func ShowTrashTaskFunc(w http.ResponseWriter, r *http.Request) {
|
|||
func ShowCompleteTasksFunc(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "GET" {
|
||||
context, err := db.GetTasks("completed", "")
|
||||
categories := db.GetCategories()
|
||||
context.Categories = categories
|
||||
if err != nil {
|
||||
http.Redirect(w, r, "/completed", http.StatusInternalServerError)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue