Documentation ¶
Index ¶
- Variables
- func CollectLabels(rows *sql.Rows, hasAccount bool) *models.Benchmark
- func ConnectDb() *gorm.DB
- func ConnectNewDb() *pg.DB
- func Decode(r io.ReadCloser, v interface{}) error
- func Encode(w http.ResponseWriter, v interface{}, status int)
- func FindAccount(db *gorm.DB, username string) (*models.Account, error)
- func FindTemplate(db *gorm.DB, reqTpl string, accountID string) (models.Templates, error)
- func GetAccountQualities(db *gorm.DB) (*models.AccountQuality, error)
- func GetConstraints(db *gorm.DB)
- func GetRecordingLabels(db *gorm.DB, recordingID string, opener int, closer int) (interface{}, error)
- func GetSpectrograms(db *gorm.DB, window int) (*[]models.Spectrogram, error)
- func GetSystemBenchmarkGroup(db *gorm.DB) (*models.Benchmark, error)
- func GetTables(lbl models.Label) []string
- func GetTemplateLabel(db *gorm.DB, templateID string, number int) (interface{}, error)
- func GetUserBenchmarkGroup(db *gorm.DB, acc *models.Account) (*models.Benchmark, error)
- func IsError(err error, constraint DbHTTPErr) bool
- func Migrate()
- func ParseErrors(err []error, key string) error
- func SetLabelKinds(lbls []models.Label) error
- func SetLabels(db *gorm.DB, cl *models.Clip) error
- func UpdateAccountFeedback(db *gorm.DB, acc *models.Account, val int) error
- type DbHTTPErr
- type FKViolationAccount
- type FKViolationTemplate
- type GeneralPqError
- type MemoryCache
- type UniqueViolationEmail
- type UniqueViolationUsername
Constants ¶
This section is empty.
Variables ¶
var FKViolationAccountErr = DbHTTPErr{"foreign_key_violation", "_account_id_fkey", http.StatusForbidden}
FKViolationAccountErr is a foreign key violation on account id
var FKViolationTemplateErr = DbHTTPErr{"foreign_key_violation", "_template_id_fkey", http.StatusBadRequest}
FKViolationTemplateErr is a foreign key violation on template id
var GenreLabels []string
GenreLabels contains the instrument constraints
var InstrumentLabels []string
InstrumentLabels contains the instrument constraints
var LabelConstraints map[string]*models.RecordingLabel
LabelConstraints contains the label constraints
var MoodLabels []string
MoodLabels contains the instrument constraints
var UniqueViolationEmailErr = DbHTTPErr{"unique_violation", "_email_key", http.StatusConflict}
UniqueViolationEmailErr is a unique violation error on email
var UniqueViolationUsernameErr = DbHTTPErr{"unique_violation", "_username_key", http.StatusConflict}
UniqueViolationUsernameErr is a unique violation error on email
Functions ¶
func CollectLabels ¶
CollectLabels returns a benchmark from SQL recording labels
Expects rows to be in sorted order by the benchmark group, i.e. recording ID.
func Decode ¶
func Decode(r io.ReadCloser, v interface{}) error
Decode tries to decode the interface as json
func Encode ¶
func Encode(w http.ResponseWriter, v interface{}, status int)
Encode writes the encoded value
func FindAccount ¶
FindAccount returns an account object
func FindTemplate ¶
FindTemplate gets an existing template
func GetAccountQualities ¶
func GetAccountQualities(db *gorm.DB) (*models.AccountQuality, error)
GetAccountQualities loads account quality data from the database
func GetRecordingLabels ¶
func GetRecordingLabels(db *gorm.DB, recordingID string, opener int, closer int) (interface{}, error)
GetRecordingLabels retrieves labels for a template
func GetSpectrograms ¶
GetSpectrograms returns spectrograms matching the given window
func GetSystemBenchmarkGroup ¶
GetSystemBenchmarkGroup returns a benchmark group tied to all users
func GetTables ¶
GetTables get the tables for a corresponding label
func GetTemplateLabel ¶
GetTemplateLabel retrieves labels for a template
func GetUserBenchmarkGroup ¶
GetUserBenchmarkGroup returns a benchmark group If an account is provided, get a group relevant to that user If an account is not provided, get the entire system benchmark that contains user metadata
func IsError ¶
IsError checks for database pq errors
func ParseErrors ¶
ParseErrors parses the database errors
func SetLabelKinds ¶
SetLabelKinds sets the label kinds
Types ¶
type DbHTTPErr ¶
DbHTTPErr contains a mapping of database errors with HTTP statuses
type FKViolationAccount ¶
type FKViolationAccount struct {
AccountID *string
}
FKViolationAccount formats violation info
func (*FKViolationAccount) Error ¶
func (e *FKViolationAccount) Error() string
type FKViolationTemplate ¶
type FKViolationTemplate struct {
TemplateID string
}
FKViolationTemplate formats violation info
func (*FKViolationTemplate) Error ¶
func (e *FKViolationTemplate) Error() string
type GeneralPqError ¶
type GeneralPqError struct{}
GeneralPqError has violation information
func (*GeneralPqError) Error ¶
func (e *GeneralPqError) Error() string
type MemoryCache ¶
type MemoryCache struct { Lock sync.RWMutex ClipIDClipMap map[string]*models.Clip `json:"omitempty"` ClipIDSlice []*string `json:"omitempty"` LblRecMap map[string]internal.Set `json:"omitempty"` RecClipMap map[string]internal.Set `json:"omitempty"` MemSel memoizedMap }
MemoryCache represents a memory cache of clips
func NewMemoryCache ¶
func NewMemoryCache() *MemoryCache
NewMemoryCache returns an initialized MemoryCache
func (*MemoryCache) ClipByClipID ¶
func (mc *MemoryCache) ClipByClipID(clipID string) *models.Clip
ClipByClipID gets a clip by clipID
func (*MemoryCache) GetClipSelection ¶
func (mc *MemoryCache) GetClipSelection(lbls []models.TemplateLabel) []*string
GetClipSelection gets the clip selection
type UniqueViolationEmail ¶
type UniqueViolationEmail struct {
Email string
}
UniqueViolationEmail formats violation info
func (*UniqueViolationEmail) Error ¶
func (e *UniqueViolationEmail) Error() string
type UniqueViolationUsername ¶
type UniqueViolationUsername struct {
Username *string
}
UniqueViolationUsername formats violation info
func (*UniqueViolationUsername) Error ¶
func (e *UniqueViolationUsername) Error() string