election

package
v0.0.0-...-db5c5b6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoVotesFound = errors.New("no votes found for election")

Functions

func NewCastVoteHandler

func NewCastVoteHandler(repository electionrepository.Repository, clock clock.Clock) *castVoteHandler

func NewCloseElectionByOwnerHandler

func NewCloseElectionByOwnerHandler(
	repository electionrepository.Repository,
	clock clock.Clock,
) *closeElectionByOwnerHandler

func NewCommenceElectionHandler

func NewCommenceElectionHandler(repository electionrepository.Repository, clock clock.Clock) *commenceElectionHandler

func NewGetElectionHandler

func NewGetElectionHandler(repository electionrepository.Repository) *getElectionHandler

func NewGetElectionResultsHandler

func NewGetElectionResultsHandler(repository electionrepository.Repository) *getElectionResultsHandler

func NewGetProposalDetailsHandler

func NewGetProposalDetailsHandler(repository electionrepository.Repository) *getProposalDetailsHandler

func NewListOpenElectionsHandler

func NewListOpenElectionsHandler(repository electionrepository.Repository) *listOpenElectionsHandler

func NewListProposalsHandler

func NewListProposalsHandler(repository electionrepository.Repository) *listProposalsHandler

func NewMakeProposalHandler

func NewMakeProposalHandler(repository electionrepository.Repository, clock clock.Clock) *makeProposalHandler

Types

type CastVote

type CastVote struct {
	VoteID            string
	ElectionID        string
	UserID            string
	RankedProposalIDs []string
}

CastVote casts a ballot for a given ElectionID. RankedProposalIDs contains the ranked candidates in order of preference: first, second, third and so forth. If your first choice doesn’t have a chance to win, your ballot counts for your next choice.

type CloseElectionByOwner

type CloseElectionByOwner struct {
	ID         string
	ElectionID string
}

CloseElectionByOwner is an asynchronous command that closes an election and calculates a winner by using the Ranked Choice Voting (RCV) electoral system.

type CommenceElection

type CommenceElection struct {
	ElectionID      string
	OrganizerUserID string
	Name            string
	Description     string
}

CommenceElection instantiates a new open election that is ready for proposals and voting.

type GetElection

type GetElection struct {
	ElectionID string
}

GetElection returns a single election by ElectionID.

type GetElectionResponse

type GetElectionResponse struct {
	ElectionID        string
	OrganizerUserID   string
	Name              string
	Description       string
	WinningProposalID string
	IsClosed          bool
	CommencedAt       int
	ClosedAt          int
	SelectedAt        int
}

type GetElectionResults

type GetElectionResults struct {
	ElectionID string
}

GetElectionResults returns the results of an election.

type GetElectionResultsResponse

type GetElectionResultsResponse struct {
	ElectionID        string
	WinningProposalID string
	SelectedAt        int
}

type GetProposalDetails

type GetProposalDetails struct {
	ProposalID string
}

GetProposalDetails returns the full details of a Proposal.

type GetProposalDetailsResponse

type GetProposalDetailsResponse struct {
	ElectionID  string
	ProposalID  string
	OwnerUserID string
	Name        string
	Description string
	ProposedAt  int
}

type ListOpenElections

type ListOpenElections struct {
	Page          *int
	ItemsPerPage  *int
	SortBy        *string
	SortDirection *string
}

ListOpenElections returns a paginated result of elections that are still open.

func (ListOpenElections) ValidationRules

func (q ListOpenElections) ValidationRules() cqrs.ValidationRuleMap

type ListOpenElectionsResponse

type ListOpenElectionsResponse struct {
	OpenElections []OpenElection
	TotalResults  int
}

type ListProposals

type ListProposals struct {
	ElectionID   string
	Page         *int
	ItemsPerPage *int
}

ListProposals returns a paginated result of election proposals. Sortable options are omitted for this example.

func (ListProposals) ValidationRules

func (q ListProposals) ValidationRules() cqrs.ValidationRuleMap

type ListProposalsResponse

type ListProposalsResponse struct {
	Proposals    []Proposal
	TotalResults int
}

type MakeProposal

type MakeProposal struct {
	ElectionID  string
	ProposalID  string
	OwnerUserID string
	Name        string
	Description string
}

MakeProposal instantiates a new proposal for a given ElectionID.

type OpenElection

type OpenElection struct {
	ElectionID      string
	OrganizerUserID string
	Name            string
	Description     string
	CommencedAt     int
}

func ToOpenElection

func ToOpenElection(election electionrepository.Election) OpenElection

func ToOpenElections

func ToOpenElections(elections []electionrepository.Election) []OpenElection

type Proposal

type Proposal struct {
	ElectionID  string
	ProposalID  string
	OwnerUserID string
	Name        string
	Description string
	ProposedAt  int
}

func ToProposal

func ToProposal(proposal electionrepository.Proposal) Proposal

func ToProposals

func ToProposals(repoProposals []electionrepository.Proposal) []Proposal

Jump to

Keyboard shortcuts

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