feature(db): switch to cgo-less driver
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
Nikurasu 2024-06-16 21:26:50 +02:00
parent 95e64b8ded
commit a8bff45a8e
Signed by: Nikurasu
GPG key ID: 9E7F14C03EF1F271
6 changed files with 37 additions and 13 deletions

View file

@ -4,8 +4,10 @@ import (
"fmt" "fmt"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/yassinebenaid/godump"
"ulmer-furs.de/pretix-proxy/v2/app/service" "ulmer-furs.de/pretix-proxy/v2/app/service"
"ulmer-furs.de/pretix-proxy/v2/app/util" "ulmer-furs.de/pretix-proxy/v2/app/util"
"ulmer-furs.de/pretix-proxy/v2/config"
"ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/entities"
) )
@ -150,7 +152,7 @@ func PostPretixEventWithoutMainProduct(c *fiber.Ctx) error {
if err != nil { if err != nil {
return c.Status(fiber.StatusNotFound).SendString("Event not found") return c.Status(fiber.StatusNotFound).SendString("Event not found")
} }
attendies, err := util.GetAttendiesFromPretixJsonFindNameInSubproducts(pretixOrders, &event) attendies, err := util.GetAttendiesFromPretixJsonFindNameInProducts(pretixOrders, &event)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return c.SendStatus(fiber.StatusInternalServerError) 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...) pretixOrders.Results = append(pretixOrders.Results, next_page.Results...)
link = next_page.Next link = next_page.Next
} }
if config.Env.Debug {
godump.Dump(pretixOrders)
}
return pretixOrders, err return pretixOrders, err
} }

View file

@ -6,10 +6,10 @@ import (
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
"slices"
"sort" "sort"
"strconv" "strconv"
"golang.org/x/exp/slices"
"ulmer-furs.de/pretix-proxy/v2/app/service" "ulmer-furs.de/pretix-proxy/v2/app/service"
"ulmer-furs.de/pretix-proxy/v2/config" "ulmer-furs.de/pretix-proxy/v2/config"
"ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/entities"
@ -300,7 +300,7 @@ func GetAttendiesFromPretixJsonWithRoleQuestionNoSubproducts(pretixEvent *entiti
return attendies, nil 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 var attendies entities.AttendiesList
for _, order := range pretixEvent.Results { for _, order := range pretixEvent.Results {
if checkCanceled(order) { if checkCanceled(order) {
@ -320,25 +320,25 @@ func GetAttendiesFromPretixJsonFindNameInSubproducts(pretixEvent *entities.Preti
var indexPrivacy int var indexPrivacy int
if indexEvent != -1 { if indexEvent != -1 {
indexName = slices.IndexFunc(order.Positions[indexEvent].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName }) 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.AttendsEvent = true
attendie.Nickname = getAttendieNickname(&order, &indexName, &indexEvent) attendie.Nickname = getAttendieNickname(&order, &indexName, &indexEvent)
privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexEvent) privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexEvent)
if err != nil { if err != nil {
return nil, err return nil, err
} }
attendie.Privacy = privacy attendie.Privacy = !privacy
} }
if indexRestaurant != -1 { if indexRestaurant != -1 {
indexName = slices.IndexFunc(order.Positions[indexRestaurant].Answers, func(a entities.Pretix_Answer) bool { return a.QuestionsIdentififer == *event.QuestionIdName }) 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.AttendsRestaurant = true
attendie.Nickname = getAttendieNickname(&order, &indexName, &indexRestaurant) attendie.Nickname = getAttendieNickname(&order, &indexName, &indexRestaurant)
privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexRestaurant) privacy, err := getAttendiePrivacy(&order, &indexPrivacy, &indexRestaurant)
if err != nil { if err != nil {
return nil, err return nil, err
} }
attendie.Privacy = privacy attendie.Privacy = !privacy
} }
attendie.RegistrationTime = order.Datetime attendie.RegistrationTime = order.Datetime
attendies = append(attendies, attendie) attendies = append(attendies, attendie)

View file

@ -15,6 +15,8 @@
{{ template "regularstable" .}} {{ template "regularstable" .}}
{{ else if eq .EventType "SpecialEventRoles" }} {{ else if eq .EventType "SpecialEventRoles" }}
{{ template "specialEventRoles" . }} {{ template "specialEventRoles" . }}
{{ else if eq .EventType "SpecialEvent" }}
{{ template "specialEvent" . }}
{{ end }} {{ end }}
</main> </main>
</body> </body>

View file

@ -1,3 +1,4 @@
{{ define "specialEvent" }}
<h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1> <h1 class="textWhite">{{ .EventName }} {{ .Locals.Attendie }}</h1>
<h2 class="textWhite">{{ .Locals.Registered }}</h2> <h2 class="textWhite">{{ .Locals.Registered }}</h2>
<table> <table>

View file

@ -4,7 +4,7 @@ import (
"fmt" "fmt"
"log" "log"
"gorm.io/driver/sqlite" "github.com/glebarez/sqlite"
"gorm.io/gorm" "gorm.io/gorm"
"ulmer-furs.de/pretix-proxy/v2/entities" "ulmer-furs.de/pretix-proxy/v2/entities"
"ulmer-furs.de/pretix-proxy/v2/seeder" "ulmer-furs.de/pretix-proxy/v2/seeder"

View file

@ -1,6 +1,8 @@
module ulmer-furs.de/pretix-proxy/v2 module ulmer-furs.de/pretix-proxy/v2
go 1.19 go 1.21
toolchain go1.22.4
require ( require (
github.com/go-playground/validator/v10 v10.15.4 github.com/go-playground/validator/v10 v10.15.4
@ -13,16 +15,30 @@ require (
golang.org/x/crypto v0.15.0 golang.org/x/crypto v0.15.0
golang.org/x/text v0.14.0 golang.org/x/text v0.14.0
gorm.io/driver/sqlite v1.5.3 gorm.io/driver/sqlite v1.5.3
gorm.io/gorm v1.25.4 gorm.io/gorm v1.25.7
) )
require ( require (
github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect 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/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/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.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/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 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 ( require (
@ -31,7 +47,7 @@ require (
github.com/gofiber/template v1.8.2 // indirect github.com/gofiber/template v1.8.2 // indirect
github.com/gofiber/template/html/v2 v2.0.5 github.com/gofiber/template/html/v2 v2.0.5
github.com/gofiber/utils v1.1.0 // indirect 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/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.16.7 // 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/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.50.0 // indirect github.com/valyala/fasthttp v1.50.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 golang.org/x/exp v0.0.0-20231108232855-2478ac86f678
golang.org/x/sys v0.14.0 // indirect golang.org/x/sys v0.19.0 // indirect
) )