diff --git a/db/tasks.go b/db/tasks.go index 15574ae..977ecd5 100644 --- a/db/tasks.go +++ b/db/tasks.go @@ -2,13 +2,12 @@ package db import ( "database/sql" - "log" - "strings" - "time" - _ "github.com/mattn/go-sqlite3" //we want to use sqlite natively md "github.com/shurcooL/github_flavored_markdown" "github.com/thewhitetulip/Tasks/types" + "log" + "strings" + "time" ) var database Database @@ -162,6 +161,7 @@ func UpdateTask(id int, title string, content string) error { return err } +//taskQuery encapsulates running multiple queries which don't do much things func taskQuery(sql string, args ...interface{}) error { SQL := database.prepare(sql) tx := database.begin() @@ -170,7 +170,7 @@ func taskQuery(sql string, args ...interface{}) error { log.Println(err) tx.Rollback() } else { - log.Println(tx.Commit()) + tx.Commit() } return err } diff --git a/views/addViews.go b/views/addViews.go index 096fa19..51ce8ae 100644 --- a/views/addViews.go +++ b/views/addViews.go @@ -1,18 +1,16 @@ package views - import ( - "net/http" - "log" - "strconv" - "os" - "time" - "fmt" - "text/template" "crypto/md5" + "fmt" "github.com/thewhitetulip/Tasks/db" "io" - + "log" + "net/http" + "os" + "strconv" + "text/template" + "time" ) // UploadedFileHandler is used to handle the uploaded file related requests diff --git a/views/deleteViews.go b/views/deleteViews.go index e24fd6c..9c9391d 100644 --- a/views/deleteViews.go +++ b/views/deleteViews.go @@ -7,7 +7,6 @@ import ( "strconv" ) - //TrashTaskFunc is used to populate the trash tasks func TrashTaskFunc(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { @@ -50,7 +49,6 @@ func RestoreTaskFunc(w http.ResponseWriter, r *http.Request) { } } - //EditTaskFunc is used to edit tasks, handles "/edit/" URL func EditTaskFunc(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { @@ -67,7 +65,6 @@ func EditTaskFunc(w http.ResponseWriter, r *http.Request) { } } - //DeleteTaskFunc is used to delete a task, trash = move to recycle bin, delete = permanent delete func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { @@ -95,7 +92,6 @@ func DeleteTaskFunc(w http.ResponseWriter, r *http.Request) { } } - //RestoreFromCompleteFunc restores the task from complete to pending func RestoreFromCompleteFunc(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { diff --git a/views/otherViews.go b/views/otherViews.go index 1a4fb72..eea3bef 100644 --- a/views/otherViews.go +++ b/views/otherViews.go @@ -11,7 +11,6 @@ import ( "text/template" ) - //PopulateTemplates is used to parse all templates present in //the templates folder func PopulateTemplates() { @@ -81,7 +80,6 @@ func SearchTaskFunc(w http.ResponseWriter, r *http.Request) { } } - //UpdateTaskFunc is used to update a task, handes "/update/" URL func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { @@ -104,4 +102,4 @@ func UpdateTaskFunc(w http.ResponseWriter, r *http.Request) { message = "Method not allowed" http.Redirect(w, r, "/", http.StatusFound) } -} \ No newline at end of file +}