secretsanta

package module
v0.0.0-...-a9948f3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 13 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 {
	ByerUserID     string
	ReceiverUserID string
	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 *bolt.DB) (*SecretSanta, error)

NewWithDB initilized the database and returns a container for secret santa

func (*SecretSanta) AddUser

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

AddUser add a user to the database

func (*SecretSanta) AddYear

func (ss *SecretSanta) AddYear(year *Year) (string, 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 string) (*User, error)

GetUser gets a user by id

func (*SecretSanta) GetYear

func (ss *SecretSanta) GetYear(id string) (*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 string) error

RemoveUser remove a user by id

func (*SecretSanta) RmYear

func (ss *SecretSanta) RmYear(id string) 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) UdateUser

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

UdateUser updates a user in the database

func (*SecretSanta) UdateYear

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

UdateYear 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        string
	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 {
	ID          string
	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