database

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 9 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
	ImageLink   string
	RedirectURL string
	Object      string
}

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) (bool, error)
}

Database Interface

func GetDatabaseClient

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

GetDatabaseClient based on the configuration, any implementations to be added here

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.MongoConfiguration) (*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) (bool, error)

InitializeVideoInference with processing if it does not exist or the status is failed and return true to process else return false (either in processing or complete)

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 {
	Id          string `bson:"_id,omitempty"`
	Name        string
	Description string
	StorageLink string
}

Video Struct TODO find some alternative to annotation to make this generic

type VideoInference

type VideoInference struct {
	Id                           string `bson:"_id,omitempty"` // Video Identifier
	Status                       string // Video Inference processing status -> PROCESSING, COMPLETE, FAILED
	ObjectCountsEachSecond       string
	ObjectsToAvgFrequency        map[string]float32
	TopFiveObjectsToInterval     map[string]Interval
	TopFiveObjectsToAvgFrequency map[string]float32
}

VideoInference Struct TODO find some alternative to annotation to make this generic

Jump to

Keyboard shortcuts

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