Compare commits
20 Commits
94314ae91e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
b67eb2d778
|
|||
|
511bfb8f73
|
|||
|
b61466549e
|
|||
| c5fff78c83 | |||
| 9cdab949f4 | |||
| 610269a142 | |||
| 886feef65a | |||
| e9bd8610fe | |||
| 8ac550d160 | |||
| 895c19269b | |||
| cd5c0f18ea | |||
| 7ebdc08457 | |||
| f7bd5bd5e3 | |||
| 41c0d16428 | |||
| 514437473e | |||
| c6de5b4723 | |||
| a4a9bf571d | |||
| c60fc43f73 | |||
| c6ae5019dd | |||
| b9f8fe84d9 |
20
.gitea/workflows/checks.yaml
Normal file
20
.gitea/workflows/checks.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
name: "Check"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install dependencies for Nix setup action
|
||||
run: |
|
||||
apt update -y
|
||||
apt install sudo -y
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- name: enable kvm support
|
||||
run: |
|
||||
echo "system-features = nixos-test benchmark big-parallel kvm" >> /etc/nix/nix.conf
|
||||
echo "Added features to nix conf"
|
||||
cat /etc/nix/nix.conf
|
||||
- run: nix flake check
|
||||
10
go.mod
10
go.mod
@@ -2,12 +2,4 @@ module tasklist
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
github.com/tidwall/gjson v1.17.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
)
|
||||
require github.com/mattn/go-sqlite3 v1.14.16
|
||||
|
||||
6
go.sum
6
go.sum
@@ -1,8 +1,2 @@
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
|
||||
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
|
||||
101
main.go
101
main.go
@@ -2,60 +2,32 @@ package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
"encoding/json"
|
||||
|
||||
//"github.com/tidwall/gjson"
|
||||
_ "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: "CleanUp",
|
||||
Name: "Closing",
|
||||
Description: `(includes cleaning up, tidying up, rearranging chairs, closing or arranging somebody to lock the front and back doors)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
Name: "WeeklyToilet",
|
||||
Description: `(whiping the floor in the bathroom, clean toilet, clean sink, check soap and menstruation supplies)`,
|
||||
Description: `(whiping the floor in the bathroom, empty trash, clean toilet, clean sink, check soap and menstruation supplies)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
@@ -63,6 +35,36 @@ func GetDefaultTasks() []Task {
|
||||
Description: `(whiping the floor in kitchen, clean sink, empty trash, check surfaces)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
Name: "Trash",
|
||||
Description: `(empty the trash and take care the boxes are not ultra disgusting)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
Name: "Plants",
|
||||
Description: `(take care of the plants. they need water, but not too much!)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
Name: "Fridge",
|
||||
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,
|
||||
},
|
||||
{
|
||||
Name: "Poster Check",
|
||||
Description: `(Check current Posters in the main window, make sure they look nice and are not outdated)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
{
|
||||
Name: "Weekly Insta Post",
|
||||
Description: `(Post something on instagram, like a newly printed zine, kuefa or whatever)`,
|
||||
IsOptional: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,15 +75,6 @@ func InitDB(db_name string) *sql.DB {
|
||||
}
|
||||
|
||||
sqlStmt := "create table if not exists tasklists (name test not null primary key, Data text);"
|
||||
// promotion text, opening text, entering text, cleanup text, weeklytoilet text);
|
||||
//for _, task := range GetDefaultTasks() {
|
||||
// sqlStmt += ", " + task.Name + " text"
|
||||
//}
|
||||
|
||||
//sqlStmt += ");"
|
||||
|
||||
fmt.Println(sqlStmt)
|
||||
|
||||
_, err = db.Exec(sqlStmt)
|
||||
if err != nil {
|
||||
log.Printf("%q: %s\n", err, sqlStmt)
|
||||
@@ -132,14 +125,14 @@ 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) { stmt, err :=
|
||||
db.Prepare("select name from tasklists where name = ?")
|
||||
func InsertToDB(tasklist Tasklist, db *sql.DB) {
|
||||
stmt, err := db.Prepare("select name from tasklists where name = ?")
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -151,14 +144,14 @@ db.Prepare("select name from tasklists where name = ?")
|
||||
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 {
|
||||
@@ -171,11 +164,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
|
||||
}
|
||||
@@ -187,7 +180,7 @@ func TasksFromJson(tasks string) []Task {
|
||||
if err != nil {
|
||||
fmt.Println("Error during TasksFromJson")
|
||||
fmt.Println(err)
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -257,6 +250,18 @@ func main() {
|
||||
}
|
||||
|
||||
tmpl := template.Must(template.ParseFiles(*formsName))
|
||||
|
||||
http.HandleFunc("/api/next", func(w http.ResponseWriter, r *http.Request) {
|
||||
days := GetNextNDaysOfName(1, TASK_DAY, time.Now())
|
||||
tasklist_arr := QueryResult{make([]Tasklist, 1)}
|
||||
|
||||
for idx, day := range days {
|
||||
tasklist_arr.Tasklists[idx] = CreateTasklist(day.Format("Jan 2, 2006"), db)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, TasksToJson(tasklist_arr.Tasklists[0].Tasks))
|
||||
})
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
days := GetNextNDaysOfName(AMOUNT_DAYS, TASK_DAY, time.Now())
|
||||
tasklist_arr := QueryResult{make([]Tasklist, AMOUNT_DAYS)}
|
||||
|
||||
Reference in New Issue
Block a user