models

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerExists

func ContainerExists(publicationPoint, campaign string, dbc db.DB) bool

ContainerExists checks if the container is actually in the database

func ContainerUniqueName

func ContainerUniqueName(publicationPoint, campaign string) string

ContainerUniqueName returns the unique name for the container

func ModelExists

func ModelExists(name string, dbc db.DB) bool

ModelExists checks if the model exists in the database

Types

type Container

type Container struct {
	PublicationPoint string   `json:"publicationPoint" description:"publication point where the model will be connected to"`
	Campaign         string   `json:"campaign" description:"name for where in a potential place of the internal products, the model will be placed"`
	Models           []string `json:"models,omitempty" description:"list of models that are linked to this container"`
}

Container is used simply as reference to understand where the models are connected to Models and Containers are separate entities that have a "fake" relationship

func DeserializeContainer

func DeserializeContainer(c string) (Container, error)

DeserializeContainer attempts to convert the string in input in a container object

func GetAllContainers

func GetAllContainers(dbc db.DB) ([]Container, int, error)

GetAllContainers returns all the containers in the database

func GetContainer

func GetContainer(publicationPoint, campaign string, dbc db.DB) (Container, error)

GetContainer checks if an existing object already exists or not

func NewContainer

func NewContainer(publicationPoint, campaign string, models []string, dbc db.DB) (Container, error)

NewContainer creates a new container in the database

func (*Container) DeleteContainer

func (c *Container) DeleteContainer(dbc db.DB) error

DeleteContainer deletes the content of the container by truncating the PublicationPoint (aka setName)

func (*Container) LinkModel

func (c *Container) LinkModel(models []string, dbc db.DB) error

LinkModel append the models inside DB structure

type ItemScore

type ItemScore map[string]string

ItemScore is the object containing the recommended item and its score Example: {"item":"11","score":"0.6","type":"movie"}

func DeserializeItemScoreArray

func DeserializeItemScoreArray(s string) ([]ItemScore, error)

DeserializeItemScoreArray attempts to convert a string into an array of ItemScore

type LineError

type LineError map[string]string

LineError contains the line number as key and the error message as string Example: {"1":"error signal format",2:"error bananas too small"}

func DeserializeLineErrorArray

func DeserializeLineErrorArray(s string) ([]LineError, error)

DeserializeLineErrorArray attempts to convert a string into an array of LineError

type Model

type Model struct {
	Name         string   `json:"name" description:"name of the model that will be used"`
	SignalOrder  []string `json:"signalOrder" description:"list of ordered signals"`
	Concatenator string   `json:"concatenator" description:"character used as concatenator for SignalOrder {'|','#','_','-'}"`
}

Model is the object that acts as container for the metadata of each model

func DeserializeModel

func DeserializeModel(m string) (Model, error)

DeserializeModel takes a JSON string in input and try to convert it to a Model object

func GetAllModels

func GetAllModels(dbc db.DB) ([]Model, int, error)

GetAllModels is a convenient functions to get all the models from DB

func GetModel

func GetModel(name string, dbc db.DB) (Model, error)

GetModel returns an already existing model to the caller

func NewModel

func NewModel(name, concatenator string, signalOrder []string, dbc db.DB) (Model, error)

NewModel is invoked when a new model is created in the database.

func (*Model) CorrectSignalFormat

func (m *Model) CorrectSignalFormat(s string) bool

CorrectSignalFormat checks that the signal format is correct

func (*Model) DeleteModel

func (m *Model) DeleteModel(dbc db.DB) error

DeleteModel truncate all the data belonging to a model

func (*Model) GetDataPreview

func (m *Model) GetDataPreview(dbc db.DB) (map[string]string, int, error)

GetDataPreview returns a limited amount of data as preview for a single model

func (*Model) RequireSignalFormat

func (m *Model) RequireSignalFormat() bool

RequireSignalFormat checks if it is required to check the signal format

func (*Model) UpdateSignalOrder

func (m *Model) UpdateSignalOrder(signalOrder []string, dbc db.DB) error

UpdateSignalOrder triggers a change in the way the signals are stored

type RecordQueue

type RecordQueue struct {
	Table string
	Entry SingleEntry
	Error *LineError
}

RecordQueue is the object used to upload the data when coming from S3 with channels

type SingleEntry

type SingleEntry struct {
	SignalID    string      `json:"signalId"`
	Recommended []ItemScore `json:"recommended"`
}

SingleEntry is the object used to unmarshal a single JSON line

func DeserializeSingleEntryArray

func DeserializeSingleEntryArray(preview map[string]string) ([]SingleEntry, error)

DeserializeSingleEntryArray returns an array of single entries object based on the data preview

Jump to

Keyboard shortcuts

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