analytics

package
v0.0.0-...-b8330c8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidID is returned when the analytics ID is invalid. ID should be greater than 0.
	ErrInvalidID = errors.New("invalid id")
	// ErrInvalidParticipantID is returned when the analytics participant ID is invalid. Participant ID should be greater than 0.
	ErrInvalidParticipantID = errors.New("invalid participant id")
	// ErrInvalidExamID is returned when the analytics exam ID is invalid. Exam ID should be greater than 0.
	ErrInvalidExamID = errors.New("invalid exam id")
	// ErrInvalidName is returned when the analytics message is invalid. Message should not be an empty string.
	ErrInvalidMessage = errors.New("invalid message")
	// ErrInvalidName is returned when the analytics create time is invalid. create time should be greater than 0.
	ErrZeroCreatedTime = errors.New("created at is zero")
)

Functions

This section is empty.

Types

type Analytics

type Analytics struct {
	ID            int32
	ParticipantID int32
	ExamID        int32
	Message       string
	CreatedAt     time.Time
}

Analytics is a analytics in an exam.

func (*Analytics) Validate

func (a *Analytics) Validate() error

Validate validates the analytics data.

func (*Analytics) ValidateNonGenerated

func (a *Analytics) ValidateNonGenerated() error

ValidateNonGenerated validates the analytics data without validating auto-generated values.

type ListFilter

type ListFilter struct {
	ExamID *int32
}

type Service

type Service interface {
	// Save saves a analytics to the store.
	Save(ctx context.Context, a Analytics) (Analytics, error)
	// GetByID returns a analytics by its ID.
	GetByID(ctx context.Context, id int32) (Analytics, error)
	// List returns a list of analytics paginated by the given parameters.
	// size is the number of analytics to return. page is the page number.
	// Returns a list of analytics and the total number of analytics.
	List(ctx context.Context, size int32, page int32, filter ListFilter) ([]Analytics, int32, error)
	// Update updates a analytics in the store.
	Update(ctx context.Context, a Analytics) (Analytics, error)
	// Delete deletes a analytics from the store by its ID.
	Delete(ctx context.Context, id int32) error
}

Service describes the interface of a service that contains business logic for analytics.

func NewService

func NewService(logger *logrus.Entry, analyticsStore Store) (Service, error)

type Store

type Store interface {
	Save(ctx context.Context, p Analytics) (Analytics, error)
	GetByID(ctx context.Context, id int32) (Analytics, error)
	ListAll(ctx context.Context) ([]Analytics, error)
	ListAllByExamID(ctx context.Context, examID int32) ([]Analytics, error)
	ListPaginated(ctx context.Context, offset int32, limit int32) ([]Analytics, error)
	GetTotalSize(ctx context.Context) (int32, error)
	Update(ctx context.Context, p Analytics) (Analytics, error)
	Delete(ctx context.Context, id int32) error
}

Store is the interface for storing analytics that must be implemented by a storage system.

func NewSQLiteStore

func NewSQLiteStore(logger *logrus.Logger, dbPool *sqlitex.Pool) (Store, error)

Jump to

Keyboard shortcuts

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