diff --git a/db/tasks.go b/db/tasks.go
index 801140f..b2d8396 100644
--- a/db/tasks.go
+++ b/db/tasks.go
@@ -10,6 +10,7 @@ DeleteAll()
import (
"database/sql"
"log"
+ "strconv"
"strings"
"time"
@@ -121,6 +122,19 @@ func GetTasks(username, status, category string) (types.Context, error) {
err = rows.Scan(&task.Id, &task.Title, &task.Content, &TaskCreated, &task.Priority, &task.Category)
+ taskCompleted := 0
+ totalTasks := 0
+
+ if strings.HasPrefix(task.Content, "- [") {
+ for _, value := range strings.Split(task.Content, "\n") {
+ if strings.HasPrefix(value, "- [x]") {
+ taskCompleted += 1
+ }
+ totalTasks += 1
+ }
+ task.CompletedMsg = strconv.Itoa(taskCompleted) + " complete out of " + strconv.Itoa(totalTasks)
+ }
+
task.Content = string(md.Markdown([]byte(task.Content)))
// TaskContent = strings.Replace(TaskContent, "\n", "
", -1)
if err != nil {
diff --git a/templates/home.html b/templates/home.html
index 697fdff..4ad2fca 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -60,6 +60,7 @@
{{$value.Content}}
+ {{$value.CompletedMsg}}