fact

package
v0.0.0-...-2feadb7 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotEnoughReferences    = errors.New("You need at least 2 references!")
	NoAccountSpecified     = errors.New("No account ID was specified!")
	AllFieldsAreCompulsory = errors.New("All fields are compulsory.")
)

Functions

func CreateFact

func CreateFact(fs FactStorer, f *Fact) error

Types

type Fact

type Fact struct {
	Id              int64
	Fact            string
	Explain         string
	ExplainFurther  string
	AwaitModeration bool
	References      []Reference
	Votes           []Vote
	AccountId       int64
	CreatedAt       nullables.NullTime
	EditedAt        nullables.NullTime
	DeletedAt       nullables.NullTime
}

func (*Fact) GetScore

func (f *Fact) GetScore(currentAccountId int64) VoteScore

func (*Fact) ValidateReferences

func (f *Fact) ValidateReferences() error

if the references are fine, no error will be returned this will also add "http://" to the urls if they do not begin with it or https:// or ftp://

type FactStorer

type FactStorer interface {
	ListFacts(accountId int64, awaitModeration bool) ([]Fact, error)
	LoadFactFromId(id int64) (*Fact, error)
	DeleteFact(*Fact) error
	CreateFact(*Fact) error
	GetVoteForFact(accountId int64, factId int64) (*Vote, error)
	SaveVote(*Vote) error
	ModerateFact(f *Fact, enable bool) error
}

type Reference

type Reference struct {
	Id        int64
	FactId    int64
	Url       string
	Publisher string
	Title     string
	CreatedAt nullables.NullTime
	EditedAt  nullables.NullTime
	DeletedAt nullables.NullTime
}

type Vote

type Vote struct {
	Id        int64
	FactId    int64
	AccountId int64
	Score     int64
	CreatedAt nullables.NullTime
	DeletedAt nullables.NullTime
}

func VoteForFact

func VoteForFact(fs FactStorer, accountId int64, factId int64, up bool) (*Vote, error)

type VoteScore

type VoteScore struct {
	Ups         int64
	Downs       int64
	AccountVote int64
}

Jump to

Keyboard shortcuts

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