Compare commits

...

20 Commits

Author SHA1 Message Date
b67eb2d778 add insta task
All checks were successful
Check / tests (push) Successful in 12m44s
2025-10-20 19:38:04 +02:00
511bfb8f73 add poster task
Some checks failed
Check / tests (push) Has been cancelled
2025-10-20 19:34:55 +02:00
b61466549e add mailbox task
All checks were successful
Check / tests (push) Successful in 10m24s
2025-04-01 00:08:09 +02:00
c5fff78c83 tasks update
All checks were successful
Check / tests (push) Successful in 10m4s
2025-01-22 13:20:21 +01:00
9cdab949f4 add Fridge task
All checks were successful
Check / tests (push) Successful in 9m41s
2025-01-06 18:21:41 +01:00
610269a142 Merge pull request 'Actions Runner test' (#1) from runner_test into master
All checks were successful
Check / tests (push) Successful in 8m49s
Reviewed-on: #1
2024-10-23 23:05:17 +02:00
886feef65a fix task::Trash descr again
All checks were successful
Check / tests (push) Successful in 8m48s
Check / tests (pull_request) Successful in 9m3s
2024-10-23 22:42:41 +02:00
e9bd8610fe fix task::Trash description
All checks were successful
Check / tests (push) Successful in 8m57s
Check / tests (pull_request) Successful in 8m55s
2024-10-23 22:19:30 +02:00
8ac550d160 add kvm support via jobset
All checks were successful
Check / tests (push) Successful in 8m53s
2024-10-23 12:47:06 +02:00
895c19269b Revert 1 commits
cd5c0f1 'try fix actions kvm error'
2024-10-23 12:20:09 +02:00
cd5c0f18ea try fix actions kvm error
Some checks failed
Check / tests (push) Failing after 4m28s
https://github.com/nix-community/nixos-generators/issues/83
2024-10-23 12:12:42 +02:00
7ebdc08457 [actions] install sudo
Some checks failed
Check / tests (push) Failing after 4m34s
2024-10-23 03:17:48 +02:00
f7bd5bd5e3 try cachix use-nix-action
Some checks failed
Check / tests (push) Failing after 2m8s
2024-10-23 03:13:28 +02:00
41c0d16428 fix runner branch
Some checks failed
checks / checks-impure (push) Failing after 7m10s
2024-10-23 02:01:47 +02:00
514437473e fix runner target 2024-10-23 01:56:43 +02:00
c6de5b4723 add check runner 2024-10-23 01:54:41 +02:00
a4a9bf571d add Plants task
renam cleanup -> closing
2024-07-15 11:14:33 +02:00
c60fc43f73 add Trash as task 2024-06-25 17:03:00 +02:00
c6ae5019dd add api call 2024-06-17 21:33:03 +02:00
b9f8fe84d9 fix dependencies 2024-06-17 17:38:19 +02:00
4 changed files with 74 additions and 63 deletions

View 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
View File

@@ -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
View File

@@ -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
View File

@@ -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)}