database

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchUser = errors.New("no such user")

ErrNoSuchUser is returned when a user lookup is performed on a non-existent user

Functions

This section is empty.

Types

type Config added in v1.0.0

type Config struct {
	Path string
	Log  *log.Log
}

Config contains the necessary config options to connect to an sqlite3 database.

type DB added in v1.0.0

type DB struct {
	Config *Config
	SQL    *sql.DB
}

A DB in an instance of a karmabot database.

func New added in v1.0.0

func New(config *Config) (*DB, error)

New returns a new instance of a karmabot database and initializes it

func (*DB) GetLeaderboard added in v1.0.0

func (db *DB) GetLeaderboard(limit int) (Leaderboard, error)

GetLeaderboard returns the leaderboard with the top X users.

func (*DB) GetThrowback added in v1.4.5

func (db *DB) GetThrowback(user string) (*Throwback, error)

GetThrowback returns a random karma operation on a specific user

func (*DB) GetTotalPoints added in v1.0.0

func (db *DB) GetTotalPoints() (int, error)

GetTotalPoints returns the amount of points given or taken for all users.

func (*DB) GetUser added in v1.0.0

func (db *DB) GetUser(name string) (*User, error)

GetUser returns info about a user.

func (*DB) Init added in v1.0.0

func (db *DB) Init() error

Init initializes an sqlite3 database in order for karmabot to be able to use it

func (*DB) InsertPoints added in v1.0.0

func (db *DB) InsertPoints(points *Points) error

InsertPoints inserts a Points object into the database.

type Leaderboard

type Leaderboard []*User

The Leaderboard lists the top X users.

type Points

type Points struct {
	From, To, Reason string
	Points           int
}

Points is a karma record containing info about a karma operation.

type Throwback added in v1.4.5

type Throwback struct {
	Points

	Timestamp time.Time
}

Throwback is a karma operation that has happened

type User added in v1.0.0

type User struct {
	Name   string
	Points int
}

A User is an entry in the Leaderboard.

Jump to

Keyboard shortcuts

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