db

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB added in v0.1.0

type DB interface {
	SetupDefaults()
	AddSamples(samples ...Samples)
}

type GormDB added in v0.1.0

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

func NewPostgresDB added in v0.1.0

func NewPostgresDB(pgdb PostgresDB) (*GormDB, error)

func (*GormDB) AddSamples added in v0.1.0

func (gdb *GormDB) AddSamples(samples ...Samples)

func (*GormDB) SetupDefaults added in v0.1.0

func (gdb *GormDB) SetupDefaults()

type Outcome

type Outcome struct {
	OutcomeID     string
	Color         string
	Title         string
	TotalPoints   int
	TotalUsers    int
	TopPredictors []Predictor
	BadgeVersion  string
	BadgeSetID    string
}

type PostgresDB

type PostgresDB struct {
	Host    string
	Port    int
	SSLMode string

	User     string
	Password string

	DBName   string
	TimeZone string
}

type Predictor

type Predictor struct {
	PredictorID          string `gorm:"primarykey"`
	EventID              string
	OutcomeID            string
	ChannelID            string
	Color                string
	Points               int
	PredictedAt          time.Time
	UpdatedAt            time.Time
	UserID               string
	ResultType           string // WIN or LOSE
	ResultPointsWon      int
	ResultIsAcknowledged bool
	UserDisplayName      string
}

type Samples

type Samples struct {
	Timestamp time.Time

	EventID     string `gorm:"primarykey"`
	ChannelID   string
	ChannelName string

	CreatedAt time.Time
	EndedAt   time.Time
	LockedAt  time.Time

	CreatedBy string
	EndedBy   string
	LockedBy  string

	BlueID          string
	BlueTitle       string
	BlueTotalPoints int
	BlueTotalUsers  int
	BlueWon         bool

	PinkID          string
	PinkTitle       string
	PinkTotalPoints int
	PinkTotalUsers  int
	PinkWon         bool

	Predictors []Predictor `gorm:"foreignKey:EventID"`

	PredictionWindowSeconds int
	Status                  string // ACTIVE or LOCKED or RESOLVE_PENDING or RESOLVED
	Title                   string
}

func ToSamples

func ToSamples(e *event.Data, channel string) Samples

type TestDB added in v0.1.0

type TestDB struct {
	TestFunc func(...Samples)
}

func (*TestDB) AddSamples added in v0.1.0

func (tdb *TestDB) AddSamples(samples ...Samples)

func (*TestDB) SetupDefaults added in v0.1.0

func (tdb *TestDB) SetupDefaults()

Jump to

Keyboard shortcuts

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