data

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB() (*sqlx.DB, error)

ConnectDB Connects to postgres database

Types

type Data

type Data struct {
	Presets  Presets
	Settings Settings
	Jobs     Jobs
	Users    Users
}

Data represents the available database tables.

func New

func New() *Data

New creates a new database instance.

type Jobs

type Jobs interface {
	GetJobs(offset, count int) *[]types.Job
	GetJobByID(id int64) (*types.Job, error)
	GetJobByGUID(id string) (*types.Job, error)
	GetJobStatusByID(id int64) (string, error)
	GetJobStatusByGUID(guid string) (string, error)
	GetJobsCount() int
	GetJobsStats() (*[]Stats, error)
	CreateJob(job types.Job) *types.Job
	CreateEncodeData(ed types.EncodeData) *types.EncodeData
	UpdateEncodeDataByID(id int64, jsonString string) error
	UpdateEncodeProgressByID(id int64, progress float64) error
	UpdateJobByID(id int, job types.Job) *types.Job
	UpdateJobStatusByID(id int, status string) error
	UpdateJobStatusByGUID(guid string, status string) error
}

Jobs represents the Jobs database operations.

type JobsOp

type JobsOp struct {
	// contains filtered or unexported fields
}

JobsOp represents a job operation.

func (JobsOp) CreateEncodeData

func (j JobsOp) CreateEncodeData(ed types.EncodeData) *types.EncodeData

CreateEncodeData creates encode in database.

func (JobsOp) CreateJob

func (j JobsOp) CreateJob(job types.Job) *types.Job

CreateJob creates a job in database.

func (JobsOp) GetJobByGUID

func (j JobsOp) GetJobByGUID(id string) (*types.Job, error)

GetJobByGUID Gets a job by GUID.

func (JobsOp) GetJobByID

func (j JobsOp) GetJobByID(id int64) (*types.Job, error)

GetJobByID Gets a job by ID.

func (JobsOp) GetJobStatusByGUID

func (j JobsOp) GetJobStatusByGUID(guid string) (string, error)

GetJobStatusByGUID Gets a job status by GUID.

func (JobsOp) GetJobStatusByID

func (j JobsOp) GetJobStatusByID(id int64) (string, error)

GetJobStatusByID Gets a job status by GUID.

func (JobsOp) GetJobs

func (j JobsOp) GetJobs(offset, count int) *[]types.Job

GetJobs Gets all jobs.

func (JobsOp) GetJobsCount

func (j JobsOp) GetJobsCount() int

GetJobsCount Gets a count of all jobs.

func (JobsOp) GetJobsStats

func (j JobsOp) GetJobsStats() (*[]Stats, error)

GetJobsStats Gets a count of each status.

func (JobsOp) UpdateEncodeDataByID

func (j JobsOp) UpdateEncodeDataByID(id int64, jsonString string) error

UpdateEncodeDataByID Update encode by ID.

func (JobsOp) UpdateEncodeProgressByID

func (j JobsOp) UpdateEncodeProgressByID(id int64, progress float64) error

UpdateEncodeProgressByID Update progress by ID.

func (JobsOp) UpdateJobByID

func (j JobsOp) UpdateJobByID(id int, job types.Job) *types.Job

UpdateJobByID Update job by ID.

func (JobsOp) UpdateJobStatusByGUID

func (j JobsOp) UpdateJobStatusByGUID(guid string, status string) error

UpdateJobStatusByGUID Update job status by GUID.

func (JobsOp) UpdateJobStatusByID

func (j JobsOp) UpdateJobStatusByID(id int, status string) error

UpdateJobStatusByID Update job by ID.

type Presets

type Presets interface {
	GetPresets(offset, count int) *[]types.Preset
	GetPresetByID(id int) (*types.Preset, error)
	GetPresetByName(name string) (*types.Preset, error)
	GetPresetsCount() int
	CreatePreset(user types.Preset) (*types.Preset, error)
	UpdatePresetByID(id int, preset types.Preset) *types.Preset
	UpdatePresetStatusByID(id int, active bool) error
}

Presets represents the Presets database operations.

type PresetsOp

type PresetsOp struct {
	// contains filtered or unexported fields
}

PresetsOp represents the users operations.

func (PresetsOp) CreatePreset

func (p PresetsOp) CreatePreset(preset types.Preset) (*types.Preset, error)

CreatePreset creates a preset.

func (PresetsOp) GetPresetByID

func (p PresetsOp) GetPresetByID(id int) (*types.Preset, error)

GetPresetByID Gets a preset by ID.

func (PresetsOp) GetPresetByName

func (p PresetsOp) GetPresetByName(name string) (*types.Preset, error)

GetPresetByName Gets a preset by name.

func (PresetsOp) GetPresets

func (p PresetsOp) GetPresets(offset, count int) *[]types.Preset

GetPresets Gets all presets.

func (PresetsOp) GetPresetsCount

func (p PresetsOp) GetPresetsCount() int

GetPresetsCount Gets a count of all presets.

func (PresetsOp) UpdatePresetByID

func (p PresetsOp) UpdatePresetByID(id int, preset types.Preset) *types.Preset

UpdatePresetByID Update job by ID.

func (PresetsOp) UpdatePresetStatusByID

func (p PresetsOp) UpdatePresetStatusByID(id int, active bool) error

UpdatePresetStatusByID Update preset status by ID.

type Settings

type Settings interface {
	GetSetting(key string) types.Setting
	GetSettings() []types.Setting
	GetSettingsOptions() []types.SettingsOption
	UpdateSettings(setting map[string]string) error
	CreateOrUpdateSetting(key, value string)
	UpdateSetting(setting types.Setting) *types.Setting
	CreateSetting(setting types.Setting) *types.Setting
	SettingExists(optionID int64) bool
}

Settings represents the Settings database operations.

type SettingsOp

type SettingsOp struct {
	// contains filtered or unexported fields
}

SettingsOp represents the settings.

func (SettingsOp) CreateOrUpdateSetting

func (s SettingsOp) CreateOrUpdateSetting(key, value string)

CreateOrUpdateSetting Runs an "upsert"-like transaction for a setting.

func (SettingsOp) CreateSetting

func (s SettingsOp) CreateSetting(setting types.Setting) *types.Setting

CreateSetting Creates a setting.

func (SettingsOp) GetSetting

func (s SettingsOp) GetSetting(key string) types.Setting

GetSetting Gets a setting.

func (SettingsOp) GetSettings

func (s SettingsOp) GetSettings() []types.Setting

GetSettings Gets settings.

func (SettingsOp) GetSettingsOptions

func (s SettingsOp) GetSettingsOptions() []types.SettingsOption

GetSettingsOptions Gets all available setting options.

func (SettingsOp) SettingExists

func (s SettingsOp) SettingExists(optionID int64) bool

SettingExists Queries a setting exists.

func (SettingsOp) UpdateSetting

func (s SettingsOp) UpdateSetting(setting types.Setting) *types.Setting

UpdateSetting updates an existing setting.

func (SettingsOp) UpdateSettings

func (s SettingsOp) UpdateSettings(setting map[string]string) error

UpdateSettings Updates settings.

type Stats

type Stats struct {
	Status string `db:"status" json:"status"`
	Count  int    `db:"count" json:"count"`
}

Stats struct for displaying status and count of a job.

type Users

type Users interface {
	CreateUser(user types.User) (*types.User, error)
	GetUserByUsername(username string) (*types.User, error)
	GetUserID(username string) int64
}

Users represents the Users database operations.

type UsersOp

type UsersOp struct {
	// contains filtered or unexported fields
}

UsersOp represents the users operations.

func (UsersOp) CreateUser

func (u UsersOp) CreateUser(user types.User) (*types.User, error)

CreateUser creates a user.

func (UsersOp) GetUserByUsername

func (u UsersOp) GetUserByUsername(username string) (*types.User, error)

GetUserByUsername Gets a user by username.

func (UsersOp) GetUserID

func (u UsersOp) GetUserID(username string) int64

GetUserID Gets a user ID by username.

Jump to

Keyboard shortcuts

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