models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTeams

func AddTeams(count int) error

AddTeams adds the given number of teams

func InitDB

func InitDB()

func TeamActivityOverview

func TeamActivityOverview() ([]map[string]interface{}, error)

TeamActivityOverview returns a list of teams and their activity

Types

type Instance

type Instance struct {
	ID        string    `bun:",pk,type:varchar(36)" json:"id"`
	Name      string    `bun:",type:varchar(255)" json:"name"`
	UserId    string    `bun:",type:varchar(36)" json:"user_id"`
	User      User      `bun:"rel:has-one,join:user_id=user_id" json:"user"`
	Teams     Teams     `bun:"rel:has-many,join:id=instance_id" json:"teams"`
	Locations Locations `bun:"rel:has-many,join:id=instance_id" json:"locations"`
	Scans     Scans     `bun:"rel:has-many,join:id=instance_id" json:"scans"`
	// contains filtered or unexported fields
}

Instance represents a single planned activity belonging to a user Instance is used to match users, teams, locations, and scans

func FindInstanceByID

func FindInstanceByID(id string) (*Instance, error)

FindInstanceByID finds an instance by ID

func (*Instance) Delete

func (i *Instance) Delete() error

func (*Instance) GeneratePosters

func (i *Instance) GeneratePosters() (string, error)

func (*Instance) Save

func (i *Instance) Save() error

func (*Instance) Update

func (i *Instance) Update() error

func (*Instance) ZipPosters

func (i *Instance) ZipPosters() (string, error)

func (*Instance) ZipQRCodes

func (i *Instance) ZipQRCodes() (string, error)

type Instances

type Instances []Instance

func FindAllInstances

func FindAllInstances(userId string) (Instances, error)

FindAllInstances finds all instances

type Location

type Location struct {
	Code         string  `bun:",unique,pk" json:"code"`
	Lat          float64 `bun:",type:float" json:"lat"`
	Lng          float64 `bun:",type:float" json:"lng"`
	Name         string  `bun:",type:varchar(255)" json:"name"`
	Content      string  `bun:",type:text" json:"content"`
	TotalVisits  int     `bun:",type:int" json:"total_visits"`
	CurrentCount int     `bun:",type:int" json:"current_count"`
	AvgDuration  float64 `bun:",type:float" json:"avg_duration"`
	MustScanOut  bool    `bun:"default:false" json:"must_scan_out"`
	// contains filtered or unexported fields
}

func FindAllLocations

func FindAllLocations() ([]*Location, error)

FindAll returns all locations

func FindLocationByCode

func FindLocationByCode(code string) (*Location, error)

FindLocationByCode returns a location by code

func (*Location) GenerateQRCode

func (l *Location) GenerateQRCode() error

func (*Location) LogScan

func (l *Location) LogScan(teamCode string) error

LogScan creates a new scan entry for the location if it's valid

func (*Location) LogScanOut

func (l *Location) LogScanOut(teamCode string) error

func (*Location) Save

func (l *Location) Save() error

Save saves or updates a location

type Locations

type Locations []*Location

func FindLocationsByCodes

func FindLocationsByCodes(codes []string) Locations

FindLocationsByCodes returns a list of locations by code

type Scan

type Scan struct {
	TeamID     string    `bun:",pk,type:string" json:"team_id"`
	LocationID string    `bun:",pk,type:string" json:"location_id"`
	TimeIn     time.Time `bun:",type:datetime" json:"time_in"`
	TimeOut    time.Time `bun:",type:datetime" json:"time_out"`
	Location   Location  `bun:"rel:has-one,join:location_id=code" json:"location"`
	// contains filtered or unexported fields
}

func FindScan

func FindScan(teamCode, locationCode string) (*Scan, error)

FindScan finds a scan by team and location

func (*Scan) Save

func (s *Scan) Save() error

Save saves or updates a scan

type Scans

type Scans []Scan

type Team

type Team struct {
	Code             string   `bun:",unique,pk" json:"code"`
	Scans            Scans    `bun:"rel:has-many,join:code=team_id" json:"scans"`
	MustScanOut      string   `bun:"" json:"must_scan_out"`
	BlockingLocation Location `bun:"rel:has-one,join:must_scan_out=code" json:"blocking_location"`
	// contains filtered or unexported fields
}

func FindTeamByCode

func FindTeamByCode(code string) (*Team, error)

FindTeamByCode returns a team by code

func FindTeamByCodeAndInstance

func FindTeamByCodeAndInstance(code, instance string) (*Team, error)

FindTeamByCodeAndInstance returns a team by code

func (*Team) HasVisited

func (t *Team) HasVisited(location *Location) bool

HasVisited returns true if the team has visited the given location

func (*Team) SuggestNextLocations

func (t *Team) SuggestNextLocations(limit int) *Locations

SuggestNextLocation returns the next location to scan in

func (*Team) Update

func (t *Team) Update() error

type Teams

type Teams []Team

func FindAllTeams

func FindAllTeams() (Teams, error)

FindAll returns all teams

type User

type User struct {
	UserID    string    `bun:",pk,type:varchar(36)" json:"user_id"`
	Email     string    `bun:",unique,pk" json:"email"`
	Password  string    `bun:",type:varchar(255)" json:"password"`
	Instances Instances `bun:"rel:has-many,join:user_id=user_id" json:"instances"`
	// contains filtered or unexported fields
}

func AuthenticateUser

func AuthenticateUser(email, password string) (*User, error)

AuthenticateUser checks the user's credentials and returns the user if they are valid

func FindUserByEmail

func FindUserByEmail(email string) (*User, error)

FindUserByEmail finds a user by their email address

func (*User) Save

func (u *User) Save() error

Save the user to the database

type Users

type Users []*User

Jump to

Keyboard shortcuts

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