From a8bff45a8e13f36fbff9feebd16490caa7f27695 Mon Sep 17 00:00:00 2001 From: Nikurasu Date: Sun, 16 Jun 2024 21:26:50 +0200 Subject: [PATCH] feature(db): switch to cgo-less driver --- src/app/controller/webhook_controller.go | 7 ++++++- src/app/util/pretix.go | 12 +++++------ src/app/views/index.html | 2 ++ src/app/views/specialEvent.html | 1 + src/config/database.go | 2 +- src/go.mod | 26 +++++++++++++++++++----- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/app/controller/webhook_controller.go b/src/app/controller/webhook_controller.go index 5425b8e..7f0d41a 100644 --- a/src/app/controller/webhook_controller.go +++ b/src/app/controller/webhook_controller.go @@ -4,8 +4,10 @@ import ( "fmt" "github.com/gofiber/fiber/v2" + "github.com/yassinebenaid/godump" "ulmer-furs.de/pretix-proxy/v2/app/service" "ulmer-furs.de/pretix-proxy/v2/app/util" + "ulmer-furs.de/pretix-proxy/v2/config" "ulmer-furs.de/pretix-proxy/v2/entities" ) @@ -150,7 +152,7 @@ func PostPretixEventWithoutMainProduct(c *fiber.Ctx) error { if err != nil { return c.Status(fiber.StatusNotFound).SendString("Event not found") } - attendies, err := util.GetAttendiesFromPretixJsonFindNameInSubproducts(pretixOrders, &event) + attendies, err := util.GetAttendiesFromPretixJsonFindNameInProducts(pretixOrders, &event) if err != nil { fmt.Println(err) return c.SendStatus(fiber.StatusInternalServerError) @@ -178,5 +180,8 @@ func getAllPretixOrders(organizer, event *string) (*entities.Pretix_Event, error pretixOrders.Results = append(pretixOrders.Results, next_page.Results...) link = next_page.Next } + if config.Env.Debug { + godump.Dump(pretixOrders) + } return pretixOrders, err } diff --git a/src/app/util/pretix.go b/src/app/util/pretix.go index 2f6ea59..2aef1a7 100644 --- a/src/app/util/pretix.go +++ b/src/app/util/pretix.go @@ -6,10 +6,10 @@ import ( "fmt" "io" "net/http" + "slices" "sort" "strconv" - "golang.org/x/exp/slices" "ulmer-furs.de/pretix-proxy/v2/app/service" "ulmer-furs.de/pretix-proxy/v2/config" "ulmer-furs.de/pretix-proxy/v2/entities" @@ -300,7 +300,7 @@ func GetAttendiesFromPretixJsonWithRoleQuestionNoSubproducts(pretixEvent *entiti return attendies, nil } -func GetAttendiesFromPretixJsonFindNameInSubproducts(pretixEvent *entities.Pretix_Event, event *entities.Db_Event) (entities.AttendiesList, error) { +func GetAttendiesFromPretixJsonFindNameInProducts(pretixEvent *entities.Pretix_Event, event *entities.Db_Event) (entities.AttendiesList, error) { var attendies entities.AttendiesList for _, order := range pretixEvent.Results { if checkCanceled(order) { @@ -320,25 +320,25 @@ func GetAttendiesFromPretixJsonFindNameInSubproducts(pretixEvent *entities.Preti var indexPrivacy int if indexEvent != -1 { indexName = slices.IndexFunc(order.Positions[indexEvent].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName }) - indexPrivacy = slices.IndexFunc(order.Positions[indexEvent].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName }) + indexPrivacy = slices.IndexFunc(order.Positions[indexEvent].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdPrivacy }) attendie.AttendsEvent = true attendie.Nickname = getAttendieNickname(&order, &indexName, &indexEvent) privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexEvent) if err != nil { return nil, err } - attendie.Privacy = privacy + attendie.Privacy = !privacy } if indexRestaurant != -1 { indexName = slices.IndexFunc(order.Positions[indexRestaurant].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName }) - indexPrivacy = slices.IndexFunc(order.Positions[indexRestaurant].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName }) + indexPrivacy = slices.IndexFunc(order.Positions[indexRestaurant].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdPrivacy }) attendie.AttendsRestaurant = true attendie.Nickname = getAttendieNickname(&order, &indexName, &indexRestaurant) privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexRestaurant) if err != nil { return nil, err } - attendie.Privacy = privacy + attendie.Privacy = !privacy } attendie.RegistrationTime = order.Datetime attendies = append(attendies, attendie) diff --git a/src/app/views/index.html b/src/app/views/index.html index 95e244d..e606717 100644 --- a/src/app/views/index.html +++ b/src/app/views/index.html @@ -15,6 +15,8 @@ {{ template "regularstable" .}} {{ else if eq .EventType "SpecialEventRoles" }} {{ template "specialEventRoles" . }} + {{ else if eq .EventType "SpecialEvent" }} + {{ template "specialEvent" . }} {{ end }} diff --git a/src/app/views/specialEvent.html b/src/app/views/specialEvent.html index 89e3182..022935b 100644 --- a/src/app/views/specialEvent.html +++ b/src/app/views/specialEvent.html @@ -1,3 +1,4 @@ +{{ define "specialEvent" }}

{{ .EventName }} {{ .Locals.Attendie }}

{{ .Locals.Registered }}

diff --git a/src/config/database.go b/src/config/database.go index f9b2e6f..c0a08a3 100644 --- a/src/config/database.go +++ b/src/config/database.go @@ -4,7 +4,7 @@ import ( "fmt" "log" - "gorm.io/driver/sqlite" + "github.com/glebarez/sqlite" "gorm.io/gorm" "ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/seeder" diff --git a/src/go.mod b/src/go.mod index 02d9662..706cad5 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,6 +1,8 @@ module ulmer-furs.de/pretix-proxy/v2 -go 1.19 +go 1.21 + +toolchain go1.22.4 require ( github.com/go-playground/validator/v10 v10.15.4 @@ -13,16 +15,30 @@ require ( golang.org/x/crypto v0.15.0 golang.org/x/text v0.14.0 gorm.io/driver/sqlite v1.5.3 - gorm.io/gorm v1.25.4 + gorm.io/gorm v1.25.7 ) require ( github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/glebarez/go-sqlite v1.21.2 // indirect + github.com/glebarez/sqlite v1.11.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/leodido/go-urn v1.2.4 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/yassinebenaid/godump v0.7.0 // indirect golang.org/x/net v0.10.0 // indirect + modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect + modernc.org/libc v1.52.1 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.8.0 // indirect + modernc.org/sqlite v1.30.1 // indirect + modernc.org/strutil v1.2.0 // indirect + modernc.org/token v1.1.0 // indirect ) require ( @@ -31,7 +47,7 @@ require ( github.com/gofiber/template v1.8.2 // indirect github.com/gofiber/template/html/v2 v2.0.5 github.com/gofiber/utils v1.1.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/klauspost/compress v1.16.7 // indirect @@ -44,6 +60,6 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.50.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect - golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 - golang.org/x/sys v0.14.0 // indirect + golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 + golang.org/x/sys v0.19.0 // indirect )