database

package
v0.0.0-...-681265f Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryTypeStreams int = 1
	QueryTypeFollows int = 2
)

Variables

This section is empty.

Functions

func AddClipToDB

func AddClipToDB(ClipID string, CreatedAt time.Time,
	ImageUrl string, ClipUrl string, ChannelName string)

AddClipToDB inserts a clip into the database if it does not already exist.

func AddThumbToDB

func AddThumbToDB(roundTime time.Time, ChannelName string,
	ChannelDisplayName string, VODSeconds int, VOD string,
	ImagePath string, StartTime time.Time, Title string, viewers int,
	FilterIds []uint)

AddThumbToDB adds a new Thumb to the DB, possibly creating a new Stream.

func DeleteImage

func DeleteImage(filepath string)

TODO: move this logic elsewhere?

func InitDB

func InitDB()

InitDB initializes the database.

func PruneOldStreams

func PruneOldStreams(roundTime time.Time)

PruneOldStreams removes old streams along with their thumbs, follows, and image files.

func UpdateFilter

func UpdateFilter(filterId uint, roundTime time.Time)

Types

type Clip

type Clip struct {
	gorm.Model
	ClipID        string
	StreamID      uint
	ClipCreatedAt time.Time
	ImageUrl      string
	ClipUrl       string
}

func GetStreamClips

func GetStreamClips(streamId uint) []Clip

type Filter

type Filter struct {
	gorm.Model
	Name           string `gorm:"size:50"`
	Subpath        string `gorm:"size:50"`
	QueryType      int
	QueryParam     string `gorm:"size:150"`
	LastUpdateTime time.Time
}

func GetAllFilters

func GetAllFilters() []Filter

GetAllFilters returns all filters in the DB.

func GetFilterWithSubpath

func GetFilterWithSubpath(Subpath string) *Filter

type Follow

type Follow struct {
	gorm.Model
	FilterID uint
	StreamID uint
}

type Stream

type Stream struct {
	gorm.Model
	ChannelName        string `gorm:"size:50"`
	ChannelDisplayName string `gorm:"size:50"`
	Title              string `gorm:"size:150"`
	StartTime          time.Time
	LastUpdateTime     time.Time
	AverageViewers     float32
	NumThumbs          uint
}

func GetAllStreams

func GetAllStreams() []Stream

func GetStreamByID

func GetStreamByID(streamId uint) Stream

func GetStreamsOfFilter

func GetStreamsOfFilter(filterId uint) []Stream

type Thumb

type Thumb struct {
	gorm.Model
	StreamID   uint
	VOD        string `gorm:"size:50"`
	VODSeconds int
	ImagePath  string
}

func GetStreamThumbs

func GetStreamThumbs(streamId uint) []Thumb

GetStreamThumbs returns all thumbs corresponding to a stream id.

Jump to

Keyboard shortcuts

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