models

package
v0.0.0-...-f92d658 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DBDateTimeNowSQL = "strftime('%Y-%m-%dT%H:%M:%fZ', 'now')"

Variables

This section is empty.

Functions

func ValidPuljeValues

func ValidPuljeValues() []string

Types

type AgeGroup

type AgeGroup string
const (
	AgeGroupDefault       AgeGroup = "Default"
	AgeGroupChildFriendly AgeGroup = "ChildFriendly"
	AgeGroupAdultsOnly    AgeGroup = "AdultsOnly"
)

func (AgeGroup) BadgeLabel

func (ageGroup AgeGroup) BadgeLabel() string

func (AgeGroup) Label

func (ageGroup AgeGroup) Label() string

func (AgeGroup) Valid

func (ageGroup AgeGroup) Valid() bool

type Billettholder

type Billettholder struct {
	ID           int                  `json:"id"`
	FirstName    string               `json:"first_name"`
	LastName     string               `json:"last_name"`
	Emails       []BillettholderEmail `json:"emails,omitempty"`
	TicketTypeId int                  `json:"ticket_type_id"`
	TicketType   string               `json:"ticket_type"`
	IsOver18     bool                 `json:"is_over_18"`
	OrderID      int                  `json:"order_id"`
	TicketID     int                  `json:"ticket_id"`
	CreatedAt    DBDateTime           `json:"created_at"`
	UpdatedAt    DBDateTime           `json:"updated_at"`
	CreatedByID  sql.NullInt64        `json:"created_by_id"`
	UpdatedByID  sql.NullInt64        `json:"updated_by_id"`
}

type BillettholderEmail

type BillettholderEmail struct {
	ID              int                    `json:"id"`
	BillettholderID int                    `json:"billettholder_id"`
	Email           string                 `json:"email"`
	Kind            BillettholderEmailKind `json:"kind"` // See BillettholderEmailKind constants.
	CreatedAt       DBDateTime             `json:"created_at"`
	UpdatedAt       DBDateTime             `json:"updated_at"`
	CreatedByID     sql.NullInt64          `json:"created_by_id"`
	UpdatedByID     sql.NullInt64          `json:"updated_by_id"`
}

type BillettholderEmailKind

type BillettholderEmailKind string
const (
	BillettholderEmailKindTicket     BillettholderEmailKind = "Ticket"
	BillettholderEmailKindAssociated BillettholderEmailKind = "Associated"
	BillettholderEmailKindManual     BillettholderEmailKind = "Manual"
)

func (BillettholderEmailKind) Label

func (kind BillettholderEmailKind) Label() string

type BillettholderUsers

type BillettholderUsers struct {
	BillettholderID int        `json:"billettholder_id"`
	UserID          int        `json:"user_id"`
	InsertedAt      DBDateTime `json:"inserted_at"`
}

type DBDateTime

type DBDateTime struct {
	Time  time.Time
	Valid bool
}

func NewDBDateTime

func NewDBDateTime(value time.Time) DBDateTime

func (DBDateTime) Format

func (dbDateTime DBDateTime) Format(layout string) string

func (DBDateTime) IsZero

func (dbDateTime DBDateTime) IsZero() bool

func (DBDateTime) MarshalJSON

func (dbDateTime DBDateTime) MarshalJSON() ([]byte, error)

func (*DBDateTime) Scan

func (dbDateTime *DBDateTime) Scan(value any) error

func (DBDateTime) TimeOrZero

func (dbDateTime DBDateTime) TimeOrZero() time.Time

func (*DBDateTime) UnmarshalJSON

func (dbDateTime *DBDateTime) UnmarshalJSON(value []byte) error

func (DBDateTime) Value

func (dbDateTime DBDateTime) Value() (driver.Value, error)

type Event

type Event struct {
	ID                  string         `json:"id"`
	Title               string         `json:"title"`
	Intro               string         `json:"intro"`
	Description         string         `json:"description"`
	System              string         `json:"system"`
	EventType           EventType      `json:"event_type"`
	AgeGroup            AgeGroup       `json:"age_group"`
	Runtime             Runtime        `json:"runtime"`
	HostName            string         `json:"host_name"`
	UserID              sql.NullInt64  `json:"user_id"`
	Email               string         `json:"email"`
	PhoneNumber         string         `json:"phone_number"`
	MaxPlayers          int            `json:"max_players"`
	BeginnerFriendly    bool           `json:"beginner_friendly"`
	CanBeRunInEnglish   bool           `json:"can_be_run_in_english"`
	Notes               string         `json:"notes"`
	Status              EventStatus    `json:"status"`
	CreatedAt           DBDateTime     `json:"created_at"`
	UpdatedAt           DBDateTime     `json:"updated_at"`
	CreatedByID         sql.NullInt64  `json:"created_by_id"`
	UpdatedByID         sql.NullInt64  `json:"updated_by_id"`
	StatusChangedByID   sql.NullInt64  `json:"status_changed_by_id"`
	StatusChangedAt     DBDateTime     `json:"status_changed_at"`
	StatusChangedAction sql.NullString `json:"status_changed_action"`
}

type EventCardModel

type EventCardModel struct {
	Id                string      `json:"id"`
	IsPublished       bool        `json:"is_published"`
	Title             string      `json:"title"`
	Intro             string      `json:"intro"`
	Status            EventStatus `json:"status"`
	System            string      `json:"system"`
	HostName          string      `json:"host_name"`
	EventType         EventType   `json:"event_type"`
	AgeGroup          AgeGroup    `json:"age_group"`
	Runtime           Runtime     `json:"runtime"`
	BeginnerFriendly  bool        `json:"beginner_friendly"`
	CanBeRunInEnglish bool        `json:"can_be_run_in_english"`
}

type EventPlayer

type EventPlayer struct {
	EventID         string          `json:"event_id"`
	PuljeID         string          `json:"pulje_id"`
	BillettholderID int             `json:"billettholder_id"`
	Role            EventPlayerRole `json:"role"`
	InsertedAt      DBDateTime      `json:"inserted_at"`
}

type EventPlayerRole

type EventPlayerRole string

CREATE TABLE relation_events_players (

    event_id TEXT NOT NULL,
    pulje_id TEXT NOT NULL,
    billettholder_id INTEGER NOT NULL,
    role TEXT NOT NULL DEFAULT 'Player' CHECK (role IN ('Player', 'GM')),
    -- inserted_at uses the DBDateTimeNowSQL default expression.
    inserted_at TEXT,
    PRIMARY KEY (billettholder_id, event_id, pulje_id),
    FOREIGN KEY (billettholder_id) REFERENCES billettholdere (id),
    FOREIGN KEY (event_id) REFERENCES events (id),
    FOREIGN KEY (pulje_id) REFERENCES puljer (id)
);
const (
	EventPlayerRolePlayer EventPlayerRole = "Player"
	EventPlayerRoleGM     EventPlayerRole = "GM"
)

func (EventPlayerRole) Label

func (role EventPlayerRole) Label() string

type EventPulje

type EventPulje struct {
	EventID     string        `json:"event_id"`
	PuljeID     Pulje         `json:"pulje_id"`
	IsInPulje   bool          `json:"isInPulje"`
	IsPublished bool          `json:"isPublished"`
	RoomID      sql.NullInt64 `json:"room_id"`
}

type EventStatus

type EventStatus string
const (
	EventStatusDraft     EventStatus = "Kladd"
	EventStatusSubmitted EventStatus = "Innsendt"
	EventStatusApproved  EventStatus = "Godkjent"
	EventStatusArchived  EventStatus = "Forkastet"
	EventStatusAnnounced EventStatus = "Annonsert"
)

func (EventStatus) Label

func (status EventStatus) Label() string

type EventType

type EventType string
const (
	EventTypeRoleplay  EventType = "Roleplay"
	EventTypeBoardGame EventType = "Boardgame"
	EventTypeCardGame  EventType = "Cardgame"
	EventTypeOther     EventType = "Other"
)

func (EventType) Label

func (eventType EventType) Label() string

type Interest

type Interest struct {
	BillettholderId int           `json:"billettholder_id"`
	EventId         string        `json:"event_id"`
	PuljeId         string        `json:"pulje_id"`
	InterestLevel   InterestLevel `json:"interest_level"`
	CreatedAt       DBDateTime    `json:"created_at"`
	UpdatedAt       DBDateTime    `json:"updated_at"`
	CreatedByID     sql.NullInt64 `json:"created_by_id"`
	UpdatedByID     sql.NullInt64 `json:"updated_by_id"`
}

type InterestLevel

type InterestLevel string
const (
	InterestLevelNone   InterestLevel = ""
	InterestLevelHigh   InterestLevel = "Veldig interessert"
	InterestLevelMedium InterestLevel = "Middels interessert"
	InterestLevelLow    InterestLevel = "Litt interessert"
)

func InterestLevelFromScore

func InterestLevelFromScore(score int) InterestLevel

InterestLevelFromScore reverses Score: it maps a solver preference score back to the interest level it came from, returning InterestLevelNone for any score that is not one of the defined levels (including 0).

func (InterestLevel) Emoji

func (level InterestLevel) Emoji() string

Emoji returns a short glyph for an interest level, used to show at a glance how much a seated participant wanted the game they got. These are the single source of truth for the interest glyphs and match the buttons in the interest picker (TicketHolderInterestPicker), so the two views never drift apart. InterestLevelNone deliberately returns "" — the puljefordeling box uses the empty string as the signal to substitute a 📌 pin for a manual seat that has no real interest behind it.

func (InterestLevel) Label

func (level InterestLevel) Label() string

func (InterestLevel) Score

func (level InterestLevel) Score() int

Score maps an interest level onto the solver's 1–5 preference scale. No/invalid interest returns 0, meaning no edge in the assignment graph.

func (InterestLevel) Valid

func (level InterestLevel) Valid() bool

type Pulje

type Pulje string
const (
	PuljeFredagKveld  Pulje = "FredagKveld"
	PuljeLordagMorgen Pulje = "LordagMorgen"
	PuljeLordagKveld  Pulje = "LordagKveld"
	PuljeSondagMorgen Pulje = "SondagMorgen"
)

func AllPuljer

func AllPuljer() []Pulje

func ParsePulje

func ParsePulje(s string) (Pulje, bool)

type PuljeRow

type PuljeRow struct {
	ID      Pulje       `json:"id"`
	Name    string      `json:"name"`
	Status  PuljeStatus `json:"status"`
	StartAt DBDateTime  `json:"start_at"`
	EndAt   DBDateTime  `json:"end_at"`
}

func (PuljeRow) TimeRange

func (pulje PuljeRow) TimeRange() string

type PuljeStatus

type PuljeStatus string
const (
	PuljeStatusOpen      PuljeStatus = "Open"
	PuljeStatusLocked    PuljeStatus = "Locked"
	PuljeStatusCompleted PuljeStatus = "Completed"
)

func (PuljeStatus) Label

func (status PuljeStatus) Label() string

type Room

type Room struct {
	ID                 int    `json:"id"`
	Name               string `json:"name"`
	RoomNumber         string `json:"room_number"`
	Floor              int    `json:"floor"`
	MaxConcurrentGames int    `json:"max_concurrent_games"`
	Notes              string `json:"notes"`
	IsDisabled         bool   `json:"is_disabled"`
}

type RoomByPulje

type RoomByPulje struct {
	ID                 int64
	Name               string
	RoomNumber         string
	Floor              int
	MaxConcurrentGames int
	IsDisabled         bool
	Notes              string
	AssignedEventsID   []RoomEventPuljeSummary
}

RoomByPulje is a snapshot of room delegation for a specific pulje, this is mainly used for figuring out what `max_concurrent_events` is based on a pulje, but also for the dropdown input component used in assigning rooms to an event in a pulje

func (RoomByPulje) CurrentOccupancy

func (r RoomByPulje) CurrentOccupancy() int

Helper function for getting currently assigned events to a room in a pulje

func (RoomByPulje) IsFull

func (r RoomByPulje) IsFull() bool

Helper function for quickly checking if a room is full in a pulje

func (RoomByPulje) RemainingCapacity

func (r RoomByPulje) RemainingCapacity() int

Helper function for getting available free slots for a room in a pulje

type RoomErrorKey

type RoomErrorKey string
const (
	RoomError              RoomErrorKey = "error"
	RoomErrorFloor         RoomErrorKey = "floor"
	RoomErrorIsDisabled    RoomErrorKey = "is_disabled"
	RoomErrorMaxConcurrent RoomErrorKey = "max_concurrent_games"
	RoomErrorName          RoomErrorKey = "name"
	RoomErrorNotes         RoomErrorKey = "notes"
	RoomErrorRoomNumber    RoomErrorKey = "room_number"
)

type RoomEventPuljeSummary

type RoomEventPuljeSummary struct {
	EventPuljeID string
	EventID      string
	Title        string
	MaxPlayers   int
	RoomID       int64
}

RoomEventPuljeSummary is the summary of an event in `relation_event_puljer` and used in `RoomByPulje` struct

  • `EventPuljeID` is the ID of the unique event in a pulje
  • `EventID` is the ID of the pulje the unique event is in
  • `Title` is the title of the event

type RoomEventPuljeSummaryJson

type RoomEventPuljeSummaryJson struct {
	EventPuljeID string        `json:"pulje_id"`
	EventID      string        `json:"event_id"`
	Title        string        `json:"title"`
	MaxPlayers   int           `json:"max_players"`
	RoomID       sql.NullInt64 `json:"room_id"`
}

type RoomFormErrors

type RoomFormErrors map[RoomErrorKey]string

RoomFormErrors is used in validation and error handling when creating and updating rooms

func (RoomFormErrors) AddError

func (errors RoomFormErrors) AddError(errorKey RoomErrorKey, errorMessage string)

AddError is a helper function for adding an error message

func (RoomFormErrors) GetKeys

func (errors RoomFormErrors) GetKeys() []string

func (RoomFormErrors) HasError

func (errors RoomFormErrors) HasError(errorKey RoomErrorKey) bool

HasErrors is a hepler function for quickly checking if a certain error exists

func (RoomFormErrors) HasErrors

func (errors RoomFormErrors) HasErrors() bool

HasErrors is a hepler function for quickly checking if any errors exists from validation

func (RoomFormErrors) ResetErrors

func (errors RoomFormErrors) ResetErrors()

ResetErrors resets all the errors to empty strings

type RoomFormSignals

type RoomFormSignals struct {
	ID                 int    `json:"id"`
	Name               string `json:"name"`
	RoomNumber         string `json:"room_number"`
	Floor              int    `json:"floor"`
	MaxConcurrentGames int    `json:"max_concurrent_games"`
	Notes              string `json:"notes"`
	IsDisabled         bool   `json:"is_disabled"`

	Mode        string `json:"mode"`
	FormTitle   string `json:"form_title"`
	ButtonLabel string `json:"button_label"`
}

RoomFormSignals is used in data-star input form bindings for sending signals to users

type RoomInput

type RoomInput struct {
	ID                 int
	Name               *string
	RoomNumber         *string
	Floor              *int
	MaxConcurrentGames *int
	Notes              *string
	IsDisabled         *bool
}

Normalized version of `Room` type for use when updating a room, or quering for a specific room with optional params

type RoomStatusByPulje

type RoomStatusByPulje = map[Pulje]map[int64]RoomByPulje

RoomStatusByPulje is a map of puljer containing room statuses, such as which games are assigned to that room You can access status by keys: Pulje[RoomID]

type RoomStatusRow

type RoomStatusRow struct {
	PuljeID Pulje

	RoomID             int64
	RoomName           string
	RoomNumber         string
	Floor              int
	MaxConcurrentGames int
	IsDisabled         bool
	RoomNotes          string

	EventID         sql.NullString
	EventTitle      sql.NullString
	EventMaxPlayers sql.NullInt32
}

type Runtime

type Runtime string
const (
	RunTimeNormal       Runtime = "Normal"
	RunTimeShortRunning Runtime = "ShortRunning"
	RunTimeLongRunning  Runtime = "LongRunning"
)

func (Runtime) BadgeLabel

func (runtime Runtime) BadgeLabel() string

func (Runtime) Label

func (runtime Runtime) Label() string

func (Runtime) Valid

func (runtime Runtime) Valid() bool

type User

type User struct {
	ID         int        `json:"id"`
	ExternalID string     `json:"external_id"`
	Email      string     `json:"email"`
	IsAdmin    bool       `json:"is_admin"`
	InsertedAt DBDateTime `json:"inserted_at"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL