This commit is contained in:
48
main.go
48
main.go
@@ -2,51 +2,24 @@ package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
"encoding/json"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
func GetDefaultTasks() []Task {
|
||||
return []Task{
|
||||
//{
|
||||
// Name: "Title",
|
||||
// Description: ``,
|
||||
// IsOptional: true,
|
||||
//},
|
||||
//{
|
||||
// Name: "Promotion",
|
||||
// Description: `
|
||||
// (make a post on the website to promote openings times and for each film event, posting description and announcement on telegram channel, forwarding it to telegram groups, making a fb event, making a post about fb event on the fb page, sharing the event to fb groups)
|
||||
// `,
|
||||
// IsOptional: false,
|
||||
//},
|
||||
{
|
||||
Name: "Opening",
|
||||
Description: `(checking toilet if there is toilet paper and fresh towel, refill fridge, sorting deposit bottles, quickly tidy up the place)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
//{
|
||||
// Name: "Entering",
|
||||
// Description: `(checking if there are new books to be entered into the library catalogue, categorizing them, stamping them, putting them into the book shelf)`,
|
||||
// IsOptional: true,
|
||||
//},
|
||||
//{
|
||||
// Name: "PrepareKuefa",
|
||||
// Description: `(includes preparing the cutting boards and knives and all devices needed to prepare food. Including potential visitors in this action, preparing chairs, tables and benches outside of malo for people to eat and chill outside)`,
|
||||
// IsOptional: true,
|
||||
//},
|
||||
//{
|
||||
// Name: "CookingKuefa",
|
||||
// Description: `(choosing a dish/recipe, doing shopping or arranging somebody to do shopping, cooking, serving)`,
|
||||
// IsOptional: true,
|
||||
//},
|
||||
{
|
||||
Name: "Closing",
|
||||
Description: `(includes cleaning up, tidying up, rearranging chairs, closing or arranging somebody to lock the front and back doors)`,
|
||||
@@ -77,6 +50,11 @@ func GetDefaultTasks() []Task {
|
||||
Description: `(Check the fridges (kitchen and main room) for nasty stuff and try to remove it.)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
Name: "Check Mailbox",
|
||||
Description: `(Go to mailbox, open it, look if there are letters inside, if yes bring them into malo)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,13 +115,13 @@ func CreateTasklist(date string, db *sql.DB) Tasklist {
|
||||
}
|
||||
|
||||
return Tasklist{
|
||||
Date: date,
|
||||
Date: date,
|
||||
Tasks: tasks,
|
||||
Updated: false,
|
||||
}
|
||||
}
|
||||
|
||||
func InsertToDB(tasklist Tasklist, db *sql.DB) {
|
||||
func InsertToDB(tasklist Tasklist, db *sql.DB) {
|
||||
stmt, err := db.Prepare("select name from tasklists where name = ?")
|
||||
|
||||
if err != nil {
|
||||
@@ -156,14 +134,14 @@ func InsertToDB(tasklist Tasklist, db *sql.DB) {
|
||||
err = stmt.QueryRow(tasklist.Date).Scan(&name)
|
||||
|
||||
if err != nil {
|
||||
_, err := db.Exec("insert into tasklists(name, "+ "Data" +") values(?, ?)", tasklist.Date, TasksToJson(tasklist.Tasks))
|
||||
_, err := db.Exec("insert into tasklists(name, "+"Data"+") values(?, ?)", tasklist.Date, TasksToJson(tasklist.Tasks))
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error during insert: ", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
_, err := db.Exec("update tasklists set " + "Data" +" = ? where name = ?", TasksToJson(tasklist.Tasks), tasklist.Date)
|
||||
_, err := db.Exec("update tasklists set "+"Data"+" = ? where name = ?", TasksToJson(tasklist.Tasks), tasklist.Date)
|
||||
fmt.Println(TasksToJson(tasklist.Tasks))
|
||||
|
||||
if err != nil {
|
||||
@@ -176,11 +154,11 @@ type Task struct {
|
||||
Name string `json:"Name"`
|
||||
Description string `json:"Description"`
|
||||
Value string `json:"Value"`
|
||||
IsOptional bool `json:"IsOptional"`
|
||||
IsOptional bool `json:"IsOptional"`
|
||||
}
|
||||
|
||||
type Tasklist struct {
|
||||
Date string
|
||||
Date string
|
||||
Tasks []Task
|
||||
Updated bool
|
||||
}
|
||||
@@ -192,7 +170,7 @@ func TasksFromJson(tasks string) []Task {
|
||||
if err != nil {
|
||||
fmt.Println("Error during TasksFromJson")
|
||||
fmt.Println(err)
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user