database

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	STATUS_PROCESSING = "PROCESSING"
	STATUS_COMPLETE   = "COMPLETE"
	STATUS_FAILED     = "FAILED"
)
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:"name,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
	UpdateVideoInference(context.Context, VideoInference) error
	GetVideoInference(context.Context, string) (VideoInference, error)
	InitializeVideoInference(context.Context, string) 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 added in v0.2.1

type MongoDb struct {
	Db *mongo.Database
}

MongoDb struct

func GetMongoDb added in v0.2.1

func GetMongoDb(ctx context.Context, dbConfig config.DatabaseConfiguration) (*MongoDb, error)

GetMongoDb client connection to the database

func (*MongoDb) FindAdsWithObjects added in v0.2.1

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 added in v0.2.1

func (mongoDb *MongoDb) GetAd(ctx context.Context, id string) (Advertisement, error)

GetAd from the collection

func (*MongoDb) GetAllVideos added in v0.2.1

func (mongoDb *MongoDb) GetAllVideos(ctx context.Context) ([]Video, error)

GetAllVideos from the collection

func (*MongoDb) GetVideo added in v0.2.1

func (mongoDb *MongoDb) GetVideo(ctx context.Context, id string) (Video, error)

GetVideo from the collection

func (*MongoDb) GetVideoInference added in v0.2.1

func (mongoDb *MongoDb) GetVideoInference(ctx context.Context, id string) (VideoInference, error)

GetVideoInference from the collection

func (*MongoDb) InitializeVideoInference added in v0.2.1

func (mongoDb *MongoDb) InitializeVideoInference(ctx context.Context, id string) error

func (*MongoDb) InsertAd added in v0.2.1

func (mongoDb *MongoDb) InsertAd(ctx context.Context, ad Advertisement) error

InsertAd into the collection

func (*MongoDb) InsertVideo added in v0.2.1

func (mongoDb *MongoDb) InsertVideo(ctx context.Context, video Video) error

InsertVideo into the collection

func (*MongoDb) InsertVideoInference added in v0.2.1

func (mongoDb *MongoDb) InsertVideoInference(ctx context.Context, videoInference VideoInference) error

InsertVideoInference into the collection

func (*MongoDb) UpdateVideoInference added in v0.2.1

func (mongoDb *MongoDb) UpdateVideoInference(ctx context.Context, videoInference VideoInference) error

UpdateVideoInference into the collection

type Video

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

Video Struct

type VideoInference

type VideoInference struct {
	Id                           string `bson:"_id,omitempty"`    // Video Identifier
	Status                       string `bson:"status,omitempty"` // Video Inference processing status -> PROCESSING, COMPLETE, FAILED
	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