voter

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type VoteResults

type VoteResults struct {
	ResourceId    string
	Rating        float64
	TotalVotes    int
	AllowedToVote bool
}

VoteResults return results

type Voter

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

Voter structure

func Create

func Create(storage storage.StorageInterface) Voter

Create create voter instance

func (Voter) Results

func (v Voter) Results(resourceId string, sourceId string) VoteResults

Results response

func (Voter) Vote

func (v Voter) Vote(resourceId string, sourceId string, vote float64) VoteResults

Vote for some resource 500 votes, avg - 3.9 +1 vote, 4 score 500 * 3.9 = (1950 + 4) / 501 = 3.90019 1 vote, avg - 5 +1 vote, 2 score 1 * 5 = (5 + 1) / 2 = 3

Jump to

Keyboard shortcuts

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