secretsanta

package module
v0.0.0-...-1f2e424 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pairing

type Pairing struct {
	BuyerUserID    uint32
	ReceiverUserID uint32
	Rating         float64
}

Pairing describe a with user

type SecretSanta

type SecretSanta struct {
	// contains filtered or unexported fields
}

SecretSanta manage secret santa with a db. It is a Container for a BoltDB

func New

func New(dbfile string) (*SecretSanta, error)

New open the bolt databse

func NewWithDB

func NewWithDB(db *sql.DB) (*SecretSanta, error)

NewWithDB initilized the database and returns a container for secret santa

func (*SecretSanta) AddUser

func (ss *SecretSanta) AddUser(user *User) (uint32, error)

AddUser add a user to the database

func (*SecretSanta) AddYear

func (ss *SecretSanta) AddYear(year *Year) error

AddYear add a year to the database

func (*SecretSanta) Close

func (ss *SecretSanta) Close() error

Close closed the bolt database

func (*SecretSanta) Generate

func (ss *SecretSanta) Generate(year *Year, autoSave bool, seed int64) error

Generate creates a year with pairing all enabled users, if seed is 0, unix time will be used

func (*SecretSanta) GetUser

func (ss *SecretSanta) GetUser(id uint32) (*User, error)

GetUser gets a user by id

func (*SecretSanta) GetYear

func (ss *SecretSanta) GetYear(id uint32) (*Year, error)

GetYear gets a year by id

func (*SecretSanta) ListUsers

func (ss *SecretSanta) ListUsers(disabled bool) ([]*User, error)

ListUsers lists all user in the database

func (*SecretSanta) ListYears

func (ss *SecretSanta) ListYears() ([]*Year, error)

ListYears lists all years in the database

func (*SecretSanta) PrintAll

func (ss *SecretSanta) PrintAll(w io.Writer, year *Year) error

PrintAll write a year to the writer

func (*SecretSanta) RemoveUser

func (ss *SecretSanta) RemoveUser(id uint32) error

RemoveUser remove a user by id

func (*SecretSanta) RmYear

func (ss *SecretSanta) RmYear(id uint32) error

RmYear removes a year by id

func (*SecretSanta) SendInformation

func (ss *SecretSanta) SendInformation(year *Year, tmpl string, info SendInfo) error

SendInformation sends information about a year and paring

func (*SecretSanta) UpdateUser

func (ss *SecretSanta) UpdateUser(user *User) error

UpdateUser updates a user in the database

func (*SecretSanta) UpdateYear

func (ss *SecretSanta) UpdateYear(year *Year) error

UpdateYear updates a year in the database

type SendInfo

type SendInfo func(to, text string) error

SendInfo set the information

type User

type User struct {
	ID        uint32
	Firstname string
	Lastname  string
	Enabled   bool
	Email     string
}

User is a represatation of participant

type UserSlice

type UserSlice struct {
	Users []*User
}

UserSlice is a type to sort a year slices

func (UserSlice) Len

func (us UserSlice) Len() int

func (UserSlice) Less

func (us UserSlice) Less(i, j int) bool

func (UserSlice) Swap

func (us UserSlice) Swap(i, j int)

type Year

type Year struct {
	YearID      uint32
	Description string
	Amount      float32
	Pairing     []*Pairing
}

Year is a represatation of a year

type YearSlice

type YearSlice struct {
	Years []*Year
}

YearSlice is a type to sort a year slices

func (YearSlice) Len

func (ys YearSlice) Len() int

func (YearSlice) Less

func (ys YearSlice) Less(i, j int) bool

func (YearSlice) Swap

func (ys YearSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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