database

package
v0.0.0-...-85b58fb Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForeignKeyViolation = errors.New("violated foreign key")

ErrForeignKeyViolation is an error for foreign key or unique constraint breaks

Functions

func AddTiming

func AddTiming(t *types.StatusTiming) error

func CheckVoter

func CheckVoter(v *types.Voter) (types.VoterStatus, error)

CheckVoter returns whether the user can vote or not

func ClearTimings

func ClearTimings() error

func Connect

func Connect(sl *zap.SugaredLogger) (err error)

Connect to database. Must not be called more than once.

func Fail2BanCheck

func Fail2BanCheck(ip string) (int, error)

Fail2BanCheck is the db backend of handlers.Fail2BanMiddleware

func Fail2BanFail

func Fail2BanFail(ip string) error

Fail2BanFail creates a fail record for the ip

func GetCandidateEssay

func GetCandidateEssay(id int) (*types.CandidateEssay, error)

func GetCandidates

func GetCandidates() (candidates []*types.Candidate, err error)

GetCandidates returns all the candidates.

func GetCurrentStatus

func GetCurrentStatus() (types.StatusType, error)

GetCurrentStatus returns the current status.. If it doesn't exist, it is created.

func GetResults

func GetResults() ([]types.CandidateResult, error)

GetResults returns the vote counts for each candidate

func GetTimings

func GetTimings() (timings []*types.StatusTiming, err error)

func GetWinner

func GetWinner() ([]*types.CandidateID, error)

GetWinner returns the winner(s) based on the number of vote objects

func RemoveTiming

func RemoveTiming(t types.StatusType) error

func SetCurrentStatus

func SetCurrentStatus(stat types.StatusType) error

SetCurrentStatus sets the current status

func Vote

func Vote(v *types.Vote) error

Vote is saving the vote in the db and updating the voter record

func VoteStat

func VoteStat() ([]*types.VoteStat, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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