Version: v15.11.0+incompatible Latest Latest

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

Go to latest
Published: Apr 26, 2019 License: MIT Imports: 14 Imported by: 11




View Source
const SchemaVersionID = "database"


AllModels contains all the tables contained in butler's database


func CollectionByID

func CollectionByID(conn *sqlite.Conn, id int64) *itchio.Collection

func CollectionExt

func CollectionExt(c *itchio.Collection) collectionExt

func ColumnTime

func ColumnTime(col int, stmt *sqlite.Stmt) *time.Time

func Count

func Count(conn *sqlite.Conn, model interface{}, cond builder.Cond) (int64, error)

func Delete

func Delete(conn *sqlite.Conn, model interface{}, cond builder.Cond) error

func DiscardDownloadsByCaveID

func DiscardDownloadsByCaveID(conn *sqlite.Conn, caveID string)

func DownloadKeysByGameID

func DownloadKeysByGameID(conn *sqlite.Conn, gameID int64) []*itchio.DownloadKey

func DownloadMaxPosition

func DownloadMaxPosition(conn *sqlite.Conn) int64

func DownloadMinPosition

func DownloadMinPosition(conn *sqlite.Conn) int64

func Exec

func Exec(conn *sqlite.Conn, b *builder.Builder, resultFn hades.ResultFn) error

func ExecRaw

func ExecRaw(conn *sqlite.Conn, query string, resultFn hades.ResultFn, args ...interface{}) error

func ExecWithSearch

func ExecWithSearch(conn *sqlite.Conn, b *builder.Builder, search hades.Search, resultFn hades.ResultFn) error

func GameByID

func GameByID(conn *sqlite.Conn, id int64) *itchio.Game

func GetSchemaVersion

func GetSchemaVersion(conn *sqlite.Conn) int64

func HadesContext

func HadesContext() *hades.Context

func MarkAllFresh

func MarkAllFresh(conn *sqlite.Conn, fts []FetchTarget) error

func MarshalVerdict

func MarshalVerdict(in *dash.Verdict, out *JSON) error

func Must

func Must(err error)

func MustCount

func MustCount(conn *sqlite.Conn, model interface{}, cond builder.Cond) int64

func MustDelete

func MustDelete(conn *sqlite.Conn, model interface{}, cond builder.Cond)

func MustExec

func MustExec(conn *sqlite.Conn, b *builder.Builder, resultFn hades.ResultFn)

func MustExecRaw

func MustExecRaw(conn *sqlite.Conn, query string, resultFn hades.ResultFn, args ...interface{})

func MustExecWithSearch

func MustExecWithSearch(conn *sqlite.Conn, b *builder.Builder, search hades.Search, resultFn hades.ResultFn)

func MustMarkAllFresh

func MustMarkAllFresh(conn *sqlite.Conn, fts []FetchTarget)

func MustPreload

func MustPreload(conn *sqlite.Conn, record interface{}, opts ...hades.PreloadParam)

func MustPreloadGameSales

func MustPreloadGameSales(conn *sqlite.Conn, g *itchio.Game)

func MustPreloadGamesSales

func MustPreloadGamesSales(conn *sqlite.Conn, games []*itchio.Game)

func MustSave

func MustSave(conn *sqlite.Conn, record interface{}, opts ...hades.SaveParam)

func MustSelect

func MustSelect(conn *sqlite.Conn, result interface{}, cond builder.Cond, search hades.Search)

func MustSelectOne

func MustSelectOne(conn *sqlite.Conn, result interface{}, cond builder.Cond) bool

func MustUpdate

func MustUpdate(conn *sqlite.Conn, model interface{}, where hades.WhereCond, updates ...builder.Eq)

func Preload

func Preload(conn *sqlite.Conn, record interface{}, opts ...hades.PreloadParam) error

func PreloadCaves

func PreloadCaves(conn *sqlite.Conn, caveOrCaves interface{})

func PreloadDownloads

func PreloadDownloads(conn *sqlite.Conn, downloadOrDownloads interface{})

func Save

func Save(conn *sqlite.Conn, record interface{}, opts ...hades.SaveParam) error

func Select

func Select(conn *sqlite.Conn, result interface{}, cond builder.Cond, search hades.Search) error

func SelectOne

func SelectOne(conn *sqlite.Conn, result interface{}, cond builder.Cond) (bool, error)

func SetSchemaVersion

func SetSchemaVersion(conn *sqlite.Conn, version int64)

func UnmarshalVerdict

func UnmarshalVerdict(in JSON) (*dash.Verdict, error)

func Update

func Update(conn *sqlite.Conn, model interface{}, where hades.WhereCond, updates ...builder.Eq) error

func UserByID

func UserByID(conn *sqlite.Conn, id int64) *itchio.User


type Cave

type Cave struct {
	ID string `json:"id"`

	GameID int64        `json:"gameId"`
	Game   *itchio.Game `json:"game"`

	ExternalGameID int64 `json:"externalGameId"`

	UploadID int64          `json:"uploadId"`
	Upload   *itchio.Upload `json:"upload"`
	BuildID  int64          `json:"buildId"`
	Build    *itchio.Build  `json:"build"`

	Morphing bool `json:"morphing"`
	Pinned   bool `json:"pinned"`

	InstalledAt   *time.Time `json:"installedAt"`
	LastTouchedAt *time.Time `json:"lastTouchedAt"`
	SecondsRun    int64      `json:"secondsRun"`

	SnoozedAt *time.Time `json:"snoozedAt"`

	Verdict       JSON  `json:"verdict"`
	InstalledSize int64 `json:"installedSize"`

	InstallLocationID string           `json:"installLocationId"`
	InstallLocation   *InstallLocation `json:"installLocation"`

	InstallFolderName string `json:"installFolderName"`

	// If set, InstallLocationID is empty and this is used
	// for all operations instead
	CustomInstallFolder string `json:"customInstallFolder"`

func CaveByID

func CaveByID(conn *sqlite.Conn, id string) *Cave

func CavesByGameID

func CavesByGameID(conn *sqlite.Conn, gameID int64) []*Cave

func (*Cave) Delete

func (c *Cave) Delete(conn *sqlite.Conn)

func (*Cave) GetInstallFolder

func (c *Cave) GetInstallFolder(conn *sqlite.Conn) string

func (*Cave) GetInstallLocation

func (c *Cave) GetInstallLocation(conn *sqlite.Conn) *InstallLocation

func (*Cave) GetVerdict

func (c *Cave) GetVerdict() *dash.Verdict

func (*Cave) Preload

func (c *Cave) Preload(conn *sqlite.Conn)

func (*Cave) RecordPlayTime

func (c *Cave) RecordPlayTime(playTime time.Duration)

func (*Cave) Save

func (c *Cave) Save(conn *sqlite.Conn)

func (*Cave) SaveWithAssocs

func (c *Cave) SaveWithAssocs(conn *sqlite.Conn)

func (*Cave) SetVerdict

func (c *Cave) SetVerdict(verdict *dash.Verdict)

func (*Cave) Touch

func (c *Cave) Touch()

func (*Cave) UpdateInstallTime

func (c *Cave) UpdateInstallTime()

func (*Cave) UpdateInteractions

func (c *Cave) UpdateInteractions(summary *itchio.UserGameInteractionsSummary)

type CaveHistoricalPlayTime

type CaveHistoricalPlayTime struct {
	CaveID        string `hades:"primary_key"`
	GameID        int64
	UploadID      int64
	BuildID       int64
	SecondsRun    int64
	LastTouchedAt *time.Time

	CreatedAt  *time.Time
	UploadedAt *time.Time

func CaveHistoricalPlayTimeForCaves

func CaveHistoricalPlayTimeForCaves(conn *sqlite.Conn, caves []*Cave) []*CaveHistoricalPlayTime

func (*CaveHistoricalPlayTime) MarkUploaded

func (chpt *CaveHistoricalPlayTime) MarkUploaded(conn *sqlite.Conn)

type Download

type Download struct {
	// An UUID
	ID string `json:"id" hades:"primary_key"`

	Reason     string     `json:"reason"`
	Position   int64      `json:"position"`
	StartedAt  *time.Time `json:"startedAt"`
	FinishedAt *time.Time `json:"finishedAt"`

	// Full error, complete with stack trace etc.
	Error *string `json:"error"`
	// Standard butlerd error code
	ErrorCode *int64 `json:"errorCode"`
	// Short error message (hopefully human-readable)
	ErrorMessage *string `json:"errorMessage"`

	CaveID string `json:"caveId"`

	GameID int64        `json:"gameId"`
	Game   *itchio.Game `json:"game"`

	UploadID int64          `json:"uploadId"`
	Upload   *itchio.Upload `json:"upload"`

	BuildID int64         `json:"buildId"`
	Build   *itchio.Build `json:"build"`

	StagingFolder string `json:"stagingFolder"`
	InstallFolder string `json:"installFolder"`

	InstallLocationID string `json:"installLocationId"`

	Discarded bool `json:"discarded"`
	Fresh     bool `json:"fresh"`

func AllDownloads

func AllDownloads(conn *sqlite.Conn) []*Download

func DownloadByID

func DownloadByID(conn *sqlite.Conn, downloadID string) *Download

func (*Download) Preload

func (d *Download) Preload(conn *sqlite.Conn)

func (*Download) Save

func (d *Download) Save(conn *sqlite.Conn)

type FetchInfo

type FetchInfo struct {
	// Something like "profile", "profile_collections", etc.
	ObjectType string `hades:"primary_key"`
	ObjectID   string `hades:"primary_key"`

	FetchedAt *time.Time

func GetFetchInfo

func GetFetchInfo(conn *sqlite.Conn, objectType string, objectID int64) (*FetchInfo, error)

func GetFetchInfoString

func GetFetchInfoString(conn *sqlite.Conn, objectType string, objectID string) (*FetchInfo, error)

type FetchTarget

type FetchTarget struct {
	// snake_case, like "profile_collections", "collection", "collection_games", etc.
	Type string

	// if non-empty, will be used
	StringID string

	// if StringID is empty, this is used
	ID int64

	// age after which a resource is considered stale
	TTL time.Duration

func FetchTargetForCollection

func FetchTargetForCollection(collectionID int64) FetchTarget

func FetchTargetForCollectionGames

func FetchTargetForCollectionGames(collectionID int64) FetchTarget

func FetchTargetForGame

func FetchTargetForGame(gameID int64) FetchTarget

func FetchTargetForGameUploads

func FetchTargetForGameUploads(gameID int64) FetchTarget

func FetchTargetForProfileCollections

func FetchTargetForProfileCollections(profileID int64) FetchTarget

func FetchTargetForProfileGames

func FetchTargetForProfileGames(profileID int64) FetchTarget

func FetchTargetForProfileOwnedKeys

func FetchTargetForProfileOwnedKeys(profileID int64) FetchTarget

func FetchTargetForUpload

func FetchTargetForUpload(uploadID int64) FetchTarget

func FetchTargetForUser

func FetchTargetForUser(userID int64) FetchTarget

func (FetchTarget) GetInfo

func (ft FetchTarget) GetInfo(conn *sqlite.Conn) (*FetchInfo, error)

func (FetchTarget) IsStale

func (ft FetchTarget) IsStale(conn *sqlite.Conn) (bool, error)

func (FetchTarget) Key

func (ft FetchTarget) Key() string

func (FetchTarget) MarkFresh

func (ft FetchTarget) MarkFresh(conn *sqlite.Conn) error

func (FetchTarget) MustGetInfo

func (ft FetchTarget) MustGetInfo(conn *sqlite.Conn) *FetchInfo

func (FetchTarget) MustIsStale

func (ft FetchTarget) MustIsStale(conn *sqlite.Conn) bool

func (FetchTarget) MustMarkFresh

func (ft FetchTarget) MustMarkFresh(conn *sqlite.Conn)

func (FetchTarget) Validate

func (ft FetchTarget) Validate() error

type GameUpload

type GameUpload struct {
	GameID int64        `json:"gameId" hades:"primary_key"`
	Game   *itchio.Game `json:"game"`

	UploadID int64          `json:"uploadId" hades:"primary_key"`
	Upload   *itchio.Upload `json:"upload"`

	Position int64 `json:"position"`

type InstallLocation

type InstallLocation struct {
	ID string `json:"id" hades:"primary_key"`

	Path string `json:"path"`

	Caves []*Cave `json:"caves"`

func InstallLocationByID

func InstallLocationByID(conn *sqlite.Conn, id string) *InstallLocation

func (*InstallLocation) GetCaves

func (il *InstallLocation) GetCaves(conn *sqlite.Conn) []*Cave

func (*InstallLocation) GetInstallFolder

func (il *InstallLocation) GetInstallFolder(folderName string) string

func (*InstallLocation) GetStagingFolder

func (il *InstallLocation) GetStagingFolder(installID string) string

type JSON

type JSON string

type Profile

type Profile struct {
	ID int64 `json:"id"`

	APIKey string `json:"apiKey"`

	LastConnected time.Time    `json:"lastConnected"`
	User          *itchio.User `json:"user"`
	UserID        int64        `json:"userId"`

	Developer bool `json:"developer"`
	PressUser bool `json:"pressUser"`

	ProfileCollections []*ProfileCollection  `json:"profileCollections,omitempty"`
	ProfileGames       []*ProfileGame        `json:"profileGames,omitempty"`
	OwnedKeys          []*itchio.DownloadKey `json:"ownedKeys,omitempty" hades:"foreign_key:owner_id"`

func AllProfiles

func AllProfiles(conn *sqlite.Conn) []*Profile

func ProfileByID

func ProfileByID(conn *sqlite.Conn, id int64) *Profile

func (*Profile) Save

func (p *Profile) Save(conn *sqlite.Conn)

func (*Profile) UpdateFromUser

func (p *Profile) UpdateFromUser(user *itchio.User)

type ProfileCollection

type ProfileCollection struct {
	CollectionID int64 `hades:"primary_key"`
	Collection   *itchio.Collection

	ProfileID int64 `hades:"primary_key"`
	Profile   *Profile

	Position int64

type ProfileData

type ProfileData struct {
	ProfileID int64 `json:"profileId" hades:"primary_key"`

	Key   string `json:"string" hades:"primary_key"`
	Value string `json:"value"`

type ProfileGame

type ProfileGame struct {
	GameID int64        `json:"gameId" hades:"primary_key"`
	Game   *itchio.Game `json:"game,omitempty"`

	// ID of the profile this game is associated with - they're
	// not necessarily the original owner, they just have admin
	// access to it.
	ProfileID int64    `json:"profileId" hades:"primary_key"`
	Profile   *Profile `json:"profile,omitempty"`

	Position int64 `json:"position"`

	ViewsCount     int64 `json:"viewsCount"`
	DownloadsCount int64 `json:"downloadsCount"`
	PurchasesCount int64 `json:"purchasesCount"`

	Published bool `json:"published"`

Join table for Profile <has many> Games

func ProfileGamesByGameID

func ProfileGamesByGameID(conn *sqlite.Conn, gameID int64) []*ProfileGame

type SchemaVersion

type SchemaVersion struct {
	ID      string
	Version int64


Path Synopsis

Jump to

Keyboard shortcuts

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