started "real work"

This commit is contained in:
z1glr
2025-01-10 14:06:53 +00:00
parent e2aa65b416
commit 45f600268f
30 changed files with 9811 additions and 8584 deletions

View File

@@ -4,18 +4,18 @@ import (
"github.com/johannesbuehl/golunteer/backend/pkg/db"
)
type assignments map[string]string
type assignments map[string]*string
type assignemntDB struct {
TaskName string `db:"taskName"`
UserName string `db:"userName"`
TaskName string `db:"taskName"`
UserName *string `db:"userName"`
}
func Event(eventID int) (assignments, error) {
// get the assignments from the database
var assignmentRows []assignemntDB
if err := db.DB.Select(&assignmentRows, "SELECT USERS.name AS userName, TASKS.text AS taskName FROM USER_ASSIGNMENTS JOIN USERS ON USER_ASSIGNMENTS.userName = USERS.name LEFT JOIN TASKS ON USER_ASSIGNMENTS.taskID = TASKS.id WHERE USER_ASSIGNMENTS.eventID = ?", eventID); err != nil {
if err := db.DB.Select(&assignmentRows, "SELECT USERS.name AS userName, TASKS.text AS taskName FROM USER_ASSIGNMENTS LEFT JOIN USERS ON USER_ASSIGNMENTS.userName = USERS.name LEFT JOIN TASKS ON USER_ASSIGNMENTS.taskID = TASKS.id WHERE USER_ASSIGNMENTS.eventID = ?", eventID); err != nil {
return nil, err
} else {
// transform the rows into the returned map