Documentation
¶
Index ¶
- Constants
- type DB
- func (db *DB) Close() error
- func (db *DB) GetAllCommands() ([]*models.Command, error)
- func (db *DB) GetAllSessions() ([]*models.Session, error)
- func (db *DB) GetBasicStats() (map[string]interface{}, error)
- func (db *DB) GetGamificationStats() (*gamification.UserStats, error)
- func (db *DB) GetOrCreateSession(pid int, shellType string) (*models.Session, error)
- func (db *DB) GetRecentCommands(limit int) ([]*models.Command, error)
- func (db *DB) GetRecentSessions(limit int) ([]*models.Session, error)
- func (db *DB) GetTopCommands(limit int) ([]map[string]interface{}, error)
- func (db *DB) GetUserAchievements() (map[string]*gamification.UserAchievement, error)
- func (db *DB) GetUserProgress() (*models.UserProgress, error)
- func (db *DB) Health() error
- func (db *DB) StoreCommand(cmd *models.Command) error
- func (db *DB) StoreCommandWithXP(cmd *models.Command) error
- func (db *DB) UpdateStreakAndCommands() error
- func (db *DB) UpdateUserProgress(xpGained int, newAchievements []*gamification.UserAchievement) error
Constants ¶
const ( // DatabaseName is the SQLite database filename DatabaseName = "termonaut.db" // DefaultTimeout for database operations DefaultTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps the SQLite database connection
func (*DB) GetAllCommands ¶
GetAllCommands returns all commands from the database
func (*DB) GetAllSessions ¶
GetAllSessions returns all sessions from the database
func (*DB) GetBasicStats ¶
GetBasicStats returns basic usage statistics
func (*DB) GetGamificationStats ¶
func (db *DB) GetGamificationStats() (*gamification.UserStats, error)
GetGamificationStats returns stats needed for gamification calculations
func (*DB) GetOrCreateSession ¶
GetOrCreateSession gets an active session or creates a new one
func (*DB) GetRecentCommands ¶
GetRecentCommands returns the most recent commands (limited by count)
func (*DB) GetRecentSessions ¶
GetRecentSessions returns the most recent sessions (limited by count)
func (*DB) GetTopCommands ¶
GetTopCommands returns the most frequently used commands
func (*DB) GetUserAchievements ¶
func (db *DB) GetUserAchievements() (map[string]*gamification.UserAchievement, error)
GetUserAchievements returns all earned achievements
func (*DB) GetUserProgress ¶
func (db *DB) GetUserProgress() (*models.UserProgress, error)
GetUserProgress returns current user progress
func (*DB) StoreCommand ¶
StoreCommand saves a command to the database
func (*DB) StoreCommandWithXP ¶
StoreCommandWithXP stores a command and calculates XP
func (*DB) UpdateStreakAndCommands ¶
UpdateStreakAndCommands updates streak and command counts
func (*DB) UpdateUserProgress ¶
func (db *DB) UpdateUserProgress(xpGained int, newAchievements []*gamification.UserAchievement) error
UpdateUserProgress updates user progress with XP and achievements