persistence

package
v0.0.0-...-b20e1e0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearStaleSC2ReplayStatsUpdateLocks

func ClearStaleSC2ReplayStatsUpdateLocks(orm *gorm.DB, ttl int) error

func InitializeORM

func InitializeORM(cfg config.DBConfig) (*gorm.DB, error)

func InitializeRedis

func InitializeRedis(host string, port string) (*redis.Pool, error)

Types

type DiscordChannel

type DiscordChannel struct {
	ID             uint         `gorm:"primaryKey"`
	DiscordGuildID uint         `gorm:"not null"`
	DiscordGuild   DiscordGuild `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	DiscordID      string
	Name           string
	IsDM           bool
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

func (*DiscordChannel) UpdateFromDgo

func (channel *DiscordChannel) UpdateFromDgo(dgoChannel *discordgo.Channel, orm *gorm.DB) error

type DiscordGuild

type DiscordGuild struct {
	ID        uint `gorm:"primaryKey"`
	DiscordID string
	Name      string
	OwnerID   string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func GetDMGuild

func GetDMGuild(orm *gorm.DB) (DiscordGuild, error)

func (*DiscordGuild) UpdateFromDgo

func (guild *DiscordGuild) UpdateFromDgo(dgoGuild *discordgo.Guild, orm *gorm.DB) error

type DiscordUser

type DiscordUser struct {
	ID            uint `gorm:"primaryKey"`
	DiscordID     string
	Name          string
	Discriminator string
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

func (*DiscordUser) UpdateFromDgo

func (user *DiscordUser) UpdateFromDgo(author *discordgo.User, orm *gorm.DB) error

type SC2ReplayStatsUser

type SC2ReplayStatsUser struct {
	ID                uint        `gorm:"primaryKey"`
	DiscordUserID     uint        `gorm:"not null"`
	DiscordUser       DiscordUser `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	APIKey            string
	LastReplayID      int
	LastCheckedAt     time.Time
	UpdateScheduledAt time.Time
	CreatedAt         time.Time
	UpdatedAt         time.Time
}

func SC2ReplayStatsUsersWithStaleData

func SC2ReplayStatsUsersWithStaleData(orm *gorm.DB, updateInterval int) ([]SC2ReplayStatsUser, error)

func (*SC2ReplayStatsUser) API

func (user *SC2ReplayStatsUser) API() sc2r.API

func (*SC2ReplayStatsUser) FetchLastReplay

func (user *SC2ReplayStatsUser) FetchLastReplay() (sc2r.Replay, error)

func (*SC2ReplayStatsUser) GetSubscriptions

func (user *SC2ReplayStatsUser) GetSubscriptions(db *gorm.DB) ([]Subscription, error)

func (*SC2ReplayStatsUser) LockForUpdate

func (user *SC2ReplayStatsUser) LockForUpdate(orm *gorm.DB) error

func (*SC2ReplayStatsUser) TouchLastCheckedAt

func (user *SC2ReplayStatsUser) TouchLastCheckedAt(orm *gorm.DB) error

func (*SC2ReplayStatsUser) UnlockForUpdate

func (user *SC2ReplayStatsUser) UnlockForUpdate(orm *gorm.DB) error

func (*SC2ReplayStatsUser) UpdateLastReplay

func (user *SC2ReplayStatsUser) UpdateLastReplay(orm *gorm.DB) (sc2r.Replay, bool, error)

type Subscription

type Subscription struct {
	ID                   uint               `gorm:"primaryKey"`
	DiscordChannelID     uint               `gorm:"not null"`
	DiscordChannel       DiscordChannel     `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	SC2ReplayStatsUserID uint               `gorm:"not null"`
	SC2ReplayStatsUser   SC2ReplayStatsUser `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

func (*Subscription) GetSC2ReplayStatsUser

func (subscription *Subscription) GetSC2ReplayStatsUser(db *gorm.DB) (SC2ReplayStatsUser, error)

Jump to

Keyboard shortcuts

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