rating

package
v0.0.0-...-b27e624 Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 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 AverageUser

type AverageUser struct {
	UserID    string
	Rating    float32
	NumRaters int64
}

type Claim

type Claim struct {
	ByUsrID    string
	ForSection string
	jwt.StandardClaims
}

func NewClaim

func NewClaim(issuer, byUsrID, forSection string) *Claim

type DB

type DB interface {
	errors.IsNotFoundErrChecker
	SaveRating(rating Rating) error
	Rating(byUserID, forSection, forUserID string) (*Rating, error)
	Ratings(Filter) ([]Rating, error)
	AverageUserRatings(offset int64, count int32) ([]AverageUser, error)
	UpdateUserRating(userID string, newRating float32, numRaters int64) error
}

type Filter

type Filter struct {
	ForSection *crdb.Comparison
	ForUserID  *crdb.Comparison
	ByUserID   *crdb.Comparison
	Offset     int64
	Count      int32
}

func (Filter) Validate

func (f Filter) Validate() error

type IDEr

type IDEr interface {
	NextID() (string, error)
}

type JWTEr

type JWTEr interface {
	errors.IsAuthErrChecker
	JWTValidOnClaim(JWT string, clm jwt.Claims) error
	JWTValid(JWT string) (*jwtH.AuthMSClaim, error)
}

type Manager

type Manager struct {
	errors.ErrToHTTP
	// contains filtered or unexported fields
}

func NewManager

func NewManager(jwter JWTEr, db DB, idGen IDEr) (*Manager, error)

func (*Manager) RateUser

func (m *Manager) RateUser(JWT, forUserID, comment string, rating int32) error

func (*Manager) Ratings

func (m *Manager) Ratings(JWT string, filter Filter) ([]Rating, error)

func (*Manager) SyncUserRatings

func (m *Manager) SyncUserRatings(every time.Duration) error

type Rating

type Rating struct {
	ID          string
	ForSection  string
	ForUserID   string
	ByUserID    string
	Rating      int32
	Comment     string
	Created     time.Time
	LastUpdated time.Time
}

Jump to

Keyboard shortcuts

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