Documentation
¶
Index ¶
- Constants
- Variables
- func NormalizeID(uid string) string
- type UserDB
- func (db *UserDB) AddHistory(entry *database.HistoryEntry) error
- func (db *UserDB) AddInboxMessage(msg *database.InboxMessage) (*database.InboxMessage, error)
- func (db *UserDB) AddMapping(m *database.Mapping) error
- func (db *UserDB) AddMediaHistory(entry *database.MediaHistoryEntry) (int64, error)
- func (db *UserDB) Allocate() error
- func (db *UserDB) CleanupHistory(retentionDays int) (int64, error)
- func (db *UserDB) CleanupMediaHistory(retentionDays int) (int64, error)
- func (db *UserDB) Close() error
- func (db *UserDB) CloseHangingMediaHistory() error
- func (db *UserDB) CloseMediaHistory(dbid int64, endTime time.Time, playTime int) error
- func (db *UserDB) DeleteAllInboxMessages() (int64, error)
- func (db *UserDB) DeleteInboxMessage(id int64) error
- func (db *UserDB) DeleteMapping(id int64) error
- func (db *UserDB) GetAllMappings() ([]database.Mapping, error)
- func (db *UserDB) GetDBPath() string
- func (db *UserDB) GetEnabledMappings() ([]database.Mapping, error)
- func (db *UserDB) GetHistory(lastID int) ([]database.HistoryEntry, error)
- func (db *UserDB) GetInboxMessages() ([]database.InboxMessage, error)
- func (db *UserDB) GetMapping(id int64) (database.Mapping, error)
- func (db *UserDB) GetMediaHistory(lastID, limit int) ([]database.MediaHistoryEntry, error)
- func (db *UserDB) GetSupportedZapLinkHosts() ([]string, error)
- func (db *UserDB) GetZapLinkCache(url string) (string, error)
- func (db *UserDB) GetZapLinkHost(host string) (found, zapScript bool, err error)
- func (db *UserDB) HealTimestamps(bootUUID string, trueBootTime time.Time) (int64, error)
- func (db *UserDB) MigrateUp() error
- func (db *UserDB) Open() error
- func (db *UserDB) PruneExpiredZapLinkHosts(olderThan time.Duration) (int64, error)
- func (db *UserDB) SetSQLForTesting(ctx context.Context, sqlDB *sql.DB, platform platforms.Platform) error
- func (db *UserDB) Truncate() error
- func (db *UserDB) UnsafeGetSQLDb() *sql.DB
- func (db *UserDB) UpdateMapping(id int64, m *database.Mapping) error
- func (db *UserDB) UpdateMediaHistoryTime(dbid int64, playTime int) error
- func (db *UserDB) UpdateZapLinkCache(url, zapscript string) error
- func (db *UserDB) UpdateZapLinkHost(host string, zapscript int) error
- func (db *UserDB) Vacuum() error
Constants ¶
const ( MappingTypeID = "id" MappingTypeValue = "value" MappingTypeData = "data" MatchTypeExact = "exact" MatchTypePartial = "partial" MatchTypeRegex = "regex" LegacyMappingTypeUID = "uid" LegacyMappingTypeText = "text" )
Variables ¶
var AllowedMappingTypes = []string{ MappingTypeID, MappingTypeValue, MappingTypeData, }
var AllowedMatchTypes = []string{ MatchTypeExact, MatchTypePartial, MatchTypeRegex, }
var ErrNullSQL = errors.New("UserDB is not connected")
Functions ¶
func NormalizeID ¶
Types ¶
type UserDB ¶
type UserDB struct {
// contains filtered or unexported fields
}
func (*UserDB) AddHistory ¶
func (db *UserDB) AddHistory(entry *database.HistoryEntry) error
func (*UserDB) AddInboxMessage ¶ added in v2.8.0
func (db *UserDB) AddInboxMessage(msg *database.InboxMessage) (*database.InboxMessage, error)
func (*UserDB) AddMediaHistory ¶ added in v2.7.0
func (db *UserDB) AddMediaHistory(entry *database.MediaHistoryEntry) (int64, error)
AddMediaHistory adds a new media history entry and returns the DBID.
func (*UserDB) CleanupHistory ¶ added in v2.7.0
func (*UserDB) CleanupMediaHistory ¶ added in v2.7.0
CleanupMediaHistory removes media history older than the retention period.
func (*UserDB) CloseHangingMediaHistory ¶ added in v2.7.0
CloseHangingMediaHistory closes any media history entries left open from unclean shutdowns. It sets EndTime = StartTime + PlayTime for entries where EndTime is NULL.
func (*UserDB) CloseMediaHistory ¶ added in v2.7.0
CloseMediaHistory finalizes a media history entry with end time and final play time.
func (*UserDB) DeleteAllInboxMessages ¶ added in v2.8.0
func (*UserDB) DeleteInboxMessage ¶ added in v2.8.0
func (*UserDB) DeleteMapping ¶
func (*UserDB) GetEnabledMappings ¶
func (*UserDB) GetHistory ¶
func (db *UserDB) GetHistory(lastID int) ([]database.HistoryEntry, error)
func (*UserDB) GetInboxMessages ¶ added in v2.8.0
func (db *UserDB) GetInboxMessages() ([]database.InboxMessage, error)
func (*UserDB) GetMediaHistory ¶ added in v2.7.0
func (db *UserDB) GetMediaHistory(lastID, limit int) ([]database.MediaHistoryEntry, error)
GetMediaHistory retrieves media history entries with pagination.
func (*UserDB) GetSupportedZapLinkHosts ¶ added in v2.8.0
func (*UserDB) GetZapLinkHost ¶
func (*UserDB) HealTimestamps ¶ added in v2.7.0
HealTimestamps corrects timestamps for records created with unreliable clocks (MiSTer boot without NTP). When NTP syncs, this reconstructs correct timestamps using: TrueStartTime = TrueBootTime + MonotonicStart
func (*UserDB) PruneExpiredZapLinkHosts ¶ added in v2.8.0
func (*UserDB) SetSQLForTesting ¶
func (db *UserDB) SetSQLForTesting(ctx context.Context, sqlDB *sql.DB, platform platforms.Platform) error
SetSQLForTesting allows injection of a sql.DB instance for testing purposes. This method should only be used in tests to set up in-memory databases.
func (*UserDB) UnsafeGetSQLDb ¶
func (*UserDB) UpdateMediaHistoryTime ¶ added in v2.7.0
UpdateMediaHistoryTime updates only the PlayTime for currently playing media.