Documentation
¶
Index ¶
- Constants
- Variables
- func BulkInsertElectionOutcomeResult(entities []*ElectionOutcomeResult, x ...bun.IDB) error
- func CountUsers(x ...bun.IDB) (int, error)
- func CountVotesForElection(pollID int, x ...bun.IDB) (int, error)
- func DeleteAllCandidatesForUser(userID string, x ...bun.IDB) error
- func DeleteAllUsers(x ...bun.IDB) error
- func DeleteAllVotesForPoll(pollID int, x ...bun.IDB) error
- func DeleteAllVotesForUser(userID string, x ...bun.IDB) error
- func DeleteBallotForElection(electionID int, x ...bun.IDB) error
- func DeleteCandidatesForElection(electionID int, x ...bun.IDB) error
- func DeletePollByID(pollID int, x ...bun.IDB) error
- func DeleteUser(id string, x ...bun.IDB) error
- func Get() *bun.DB
- func GetTx() (bun.Tx, error)
- func HasUserVotedInPoll(userID string, pollID int, x ...bun.IDB) (bool, error)
- func Migrate(db *bun.DB) error
- func PublishPollOutcome(id int, x ...bun.IDB) error
- type BallotEntry
- type Candidate
- type DB
- type Election
- func (e *Election) Delete(x ...bun.IDB) error
- func (e *Election) GetElection() *Election
- func (e *Election) GetFriendlyTitle() string
- func (e *Election) GetPoll() *Poll
- func (e *Election) GetReferendum() *Referendum
- func (e *Election) Insert(x ...bun.IDB) error
- func (e *Election) Update(x ...bun.IDB) error
- func (e *Election) WithCandidates(x ...bun.IDB) (*ElectionWithCandidates, error)
- type ElectionCandidate
- type ElectionOutcome
- type ElectionOutcomeResult
- type ElectionWithCandidates
- type Poll
- type PollOutcome
- type PollType
- type Pollable
- type Referendum
- func (r *Referendum) Delete(x ...bun.IDB) error
- func (r *Referendum) GetElection() *Election
- func (r *Referendum) GetFriendlyTitle() string
- func (r *Referendum) GetPoll() *Poll
- func (r *Referendum) GetReferendum() *Referendum
- func (r *Referendum) Insert(x ...bun.IDB) error
- func (r *Referendum) Update(x ...bun.IDB) error
- type ReferendumOutcome
- type User
- type Vote
Constants ¶
View Source
const ElectionPollTypeId = 1
View Source
const ReferendumPollTypeId = 2
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
View Source
var Migrations = migrate.NewMigrations()
Functions ¶
func BulkInsertElectionOutcomeResult ¶
func BulkInsertElectionOutcomeResult(entities []*ElectionOutcomeResult, x ...bun.IDB) error
func DeleteAllUsers ¶
func HasUserVotedInPoll ¶
Types ¶
type BallotEntry ¶
type BallotEntry struct { bun.BaseModel `bun:"ballot_entry" json:"-"` ID int `bun:",pk,autoincrement" json:"id"` ElectionID int `json:"electionID"` Name string `json:"name"` IsRON bool `json:"isRON"` }
func CreateBallot ¶
func GetAllBallotEntriesForElection ¶
func GetAllBallotEntriesForElection(electionID int, x ...bun.IDB) ([]*BallotEntry, error)
type Candidate ¶
type Election ¶
type Election struct { bun.BaseModel `json:"-"` ID int `bun:",pk" json:"id"` RoleName string `bun:",notnull" json:"roleName"` Description string `bun:",notnull" json:"description"` Poll *Poll `bun:"rel:belongs-to,join:id=id" json:"-"` }
func (*Election) GetElection ¶
func (*Election) GetFriendlyTitle ¶
func (*Election) GetReferendum ¶
func (e *Election) GetReferendum() *Referendum
func (*Election) WithCandidates ¶
func (e *Election) WithCandidates(x ...bun.IDB) (*ElectionWithCandidates, error)
type ElectionCandidate ¶
type ElectionOutcome ¶
type ElectionOutcome struct { bun.BaseModel `json:"-"` ID int `bun:",pk" json:"id"` Rounds int `bun:",notnull" json:"rounds"` PollOutcome *PollOutcome `bun:"rel:belongs-to,join:id=id" json:"-"` Results []*ElectionOutcomeResult `bun:"rel:has-many,join:id=election_outcome_id" json:"results"` }
type ElectionOutcomeResult ¶
type ElectionOutcomeResult struct { bun.BaseModel `json:"-"` ID int `bun:",pk,autoincrement" json:"id"` Name string `bun:",notnull" json:"name"` Round int `bun:",notnull" json:"round"` Votes int `bun:",notnull" json:"voteCount"` IsRejected bool `bun:",notnull" json:"isRejected"` IsElected bool `bun:",notnull" json:"isElected"` ElectionOutcomeID int `bun:",notnull" json:"-"` ElectionOutcome *ElectionOutcome `bun:"rel:belongs-to,join:election_outcome_id=id" json:"-"` }
type ElectionWithCandidates ¶
type ElectionWithCandidates struct { Election Candidates []*ElectionCandidate `json:"candidates"` }
type Poll ¶
type Poll struct { bun.BaseModel `json:"-"` ID int `bun:",pk,autoincrement" json:"id"` PollTypeID int `bun:",notnull" json:"-"` IsActive bool `bun:",notnull" json:"isActive"` IsConcluded bool `bun:",notnull" json:"isConcluded"` PollType *PollType `bun:"rel:has-one,join:poll_type_id=id" json:"pollType"` Election *Election `bun:"rel:has-one,join:id=id" json:"election,omitempty"` Referendum *Referendum `bun:"rel:has-one,join:id=id" json:"referendum,omitempty"` Outcome *PollOutcome `bun:"rel:has-one,join:id=poll_id" json:"-"` }
type PollOutcome ¶
type PollOutcome struct { bun.BaseModel `json:"-"` ID int `bun:",pk,autoincrement" json:"id"` PollID int `bun:",notnull,unique" json:"-"` Date time.Time `bun:",notnull,default:current_timestamp" json:"date"` Ballots int `bun:",notnull" json:"ballots"` IsPublished bool `bun:",notnull" json:"isPublished"` Poll *Poll `bun:"rel:belongs-to,join:poll_id=id" json:"poll"` ElectionOutcome *ElectionOutcome `bun:"rel:has-one,join:id=id" json:"electionOutcome,omitempty"` ReferendumOutcome *ReferendumOutcome `bun:"rel:has-one,join:id=id" json:"referendumOutcome,omitempty"` }
func CreatePollOutcome ¶
func GetOutcomeForPoll ¶
func GetOutcomeForPoll(id int, x ...bun.IDB) (*PollOutcome, error)
type Pollable ¶
type Pollable interface { GetPoll() *Poll GetFriendlyTitle() string GetElection() *Election GetReferendum() *Referendum }
type Referendum ¶
type Referendum struct { bun.BaseModel `json:"-"` ID int `bun:",pk" json:"id"` Title string `bun:",notnull" json:"title"` Question string `bun:",notnull" json:"question"` Description string `bun:",notnull" json:"description"` Poll *Poll `bun:"rel:belongs-to,join:id=id" json:"-"` }
func GetReferendum ¶
func GetReferendum(id int, x ...bun.IDB) (*Referendum, error)
func (*Referendum) GetElection ¶
func (r *Referendum) GetElection() *Election
func (*Referendum) GetFriendlyTitle ¶
func (r *Referendum) GetFriendlyTitle() string
func (*Referendum) GetPoll ¶
func (r *Referendum) GetPoll() *Poll
func (*Referendum) GetReferendum ¶
func (r *Referendum) GetReferendum() *Referendum
type ReferendumOutcome ¶
type ReferendumOutcome struct { bun.BaseModel `json:"-"` ID int `bun:",pk" json:"id"` VotesFor int `bun:",notnull" json:"votesFor"` VotesAgainst int `bun:",notnull" json:"votesAgainst"` VotesAbstain int `bun:",notnull" json:"votesAbstain"` PollOutcome *PollOutcome `bun:"rel:belongs-to,join:id=id" json:"-"` }
type User ¶
type User struct { bun.BaseModel `json:"-"` StudentID string `bun:"id,pk" json:"studentID"` Name string `json:"name"` PasswordHash string `json:"-"` IsRestricted bool `json:"isRestricted"` IsAdmin bool `json:"isAdmin"` }
Click to show internal directories.
Click to hide internal directories.