database

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MaxRetryCount            = 10
	SleepDuration            = 10
	VideoCollection          = "Videos"
	AdCollection             = "Advertisements"
	VideoInferenceCollection = "VideoInference"
)

constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Advertisement struct {
	Name        string `bson:"_id,omitempty"`
	ImageLink   string `bson:"link,omitempty"`
	RedirectURL string `bson:"redirectUrl,omitempty"`
	Object      string `bson:"object,omitempty"`
}

Advertisement Struct

type Database

type Database interface {
	InsertVideo(context.Context, Video) error
	GetVideo(context.Context, string) (Video, error)
	GetAllVideos(context.Context) ([]Video, error)
	InsertAd(context.Context, Advertisement) error
	GetAd(context.Context, string) (Advertisement, error)
	FindAdsWithObjects(context.Context, []string) ([]Advertisement, error)
	InsertVideoInference(context.Context, VideoInference) error
	GetVideoInference(context.Context, string) (VideoInference, error)
}

Database Interface

func GetDatabaseClient

func GetDatabaseClient(ctx context.Context, dbConfig config.DatabaseConfiguration) (Database, error)

GetDatabaseClient based on the configuration

type Interval

type Interval struct {
	Start int32
	End   int32
}

Interval struct

type MongoDB

type MongoDB struct {
	Db *mongo.Database
}

MongoDB struct

func GetMongoDB

func GetMongoDB(ctx context.Context, dbConfig config.DatabaseConfiguration) (*MongoDB, error)

GetMongoDB client connection to the database

func (*MongoDB) FindAdsWithObjects

func (mongoDB *MongoDB) FindAdsWithObjects(ctx context.Context, objects []string) ([]Advertisement, error)

FindAdsWithObjects find all ads that have objects in the given object list

func (*MongoDB) GetAd

func (mongoDB *MongoDB) GetAd(ctx context.Context, name string) (Advertisement, error)

GetAd from the collection

func (*MongoDB) GetAllVideos

func (mongoDB *MongoDB) GetAllVideos(ctx context.Context) ([]Video, error)

GetAllVideos from the collection

func (*MongoDB) GetVideo

func (mongoDB *MongoDB) GetVideo(ctx context.Context, name string) (Video, error)

GetVideo from the collection

func (*MongoDB) GetVideoInference

func (mongoDB *MongoDB) GetVideoInference(ctx context.Context, name string) (VideoInference, error)

GetVideoInference from the collection

func (*MongoDB) InsertAd

func (mongoDB *MongoDB) InsertAd(ctx context.Context, ad Advertisement) error

InsertAd into the collection

func (*MongoDB) InsertVideo

func (mongoDB *MongoDB) InsertVideo(ctx context.Context, video Video) error

InsertVideo into the collection

func (*MongoDB) InsertVideoInference

func (mongoDB *MongoDB) InsertVideoInference(ctx context.Context, videoInference VideoInference) error

InsertVideoInference into the collection

type Video

type Video struct {
	Name        string `bson:"_id,omitempty"` // name unique
	Description string `bson:"desc,omitempty"`
	StorageLink string `bson:"link,omitempty"`
}

Video Struct

type VideoInference

type VideoInference struct {
	Name                         string `bson:"_id,omitempty"` // video name
	ObjectCountsEachSecond       string
	ObjectsToAvgFrequency        map[string]float32
	TopFiveObjectsToInterval     map[string]Interval
	TopFiveObjectsToAvgFrequency map[string]float32 `bson:"timeToObject,omitempty"`
}

VideoInference Struct

Jump to

Keyboard shortcuts

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