db

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func FindAllUsernames

func FindAllUsernames(exclude string) []string

Finds all usernames for use in @all

func IncrementPlusplus

func IncrementPlusplus(name string, increment int) int

Atomically increments a plusplus entry and returns the new value

func InsertMessageStats

func InsertMessageStats(requestMessage telegram.RequestMessage)

func MigrateMessageStats

func MigrateMessageStats(db *gorm.DB)

Migrates the table message_stats

func MigratePlusplus

func MigratePlusplus(db *gorm.DB)

Migrates the table plusplus

func MigrateStats

func MigrateStats(db *gorm.DB)

Migrates the table stats

func UpdateStats

func UpdateStats(user telegram.User)

Is called when any new message arrives update updates that users stats

Types

type MessageStats

type MessageStats struct {
	gorm.Model
	UserID    int64     `gorm:"index;<-:create"`
	UserStats Stats     `gorm:"foreignKey:user_id;references:user_id;constraint:OnDelete:CASCADE"`
	Time      time.Time `gorm:"index;<-:create"`
	Words     int       `gorm:"<-:create"`
}

type Plusplus

type Plusplus struct {
	gorm.Model
	Name  string `gorm:"uniqueIndex;<-:create"`
	Value int    `gorm:"index;<-"`
}

Model for table plusplus

func FindPlusplusFlops

func FindPlusplusFlops() []Plusplus

Find the lowest 10 plusplus entries

func FindPlusplusTops

func FindPlusplusTops() []Plusplus

Find the top 10 plusplus entries

type Stats

type Stats struct {
	gorm.Model
	UserID   int64  `gorm:"uniqueIndex;<-:create"`
	Username string `gorm:"<-"`
	Posts    uint32 `gorm:"<-"`
	LastPost time.Time
}

Model for table stats

func FindStatsTop

func FindStatsTop() []Stats

Finds all stats sorted by the number of posts

type WordCount

type WordCount struct {
	UserID   int64
	Username string
	Words    int
}

func GetWordCounts

func GetWordCounts() []WordCount

Jump to

Keyboard shortcuts

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