settings

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

func NewService

func NewService(db *gorm.DB, version string) (*Service, error)

func (*Service) GetAll

func (s *Service) GetAll() ([]Settings, error)

GetAll returns the latest version of each setting key.

Returns:

  • []Settings: A slice of settings with the latest version for each key
  • error: Database error if the query fails

func (*Service) GetLatest

func (s *Service) GetLatest(key SettingsKey) (*Settings, error)

func (*Service) GetVersion added in v0.0.20

func (s *Service) GetVersion() string

func (*Service) GetVersionHistory

func (s *Service) GetVersionHistory(key SettingsKey, limit int) ([]Settings, error)

GetVersionHistory returns the last N versions of a setting key, ordered by version descending.

Parameters:

  • key: The settings key to get history for
  • limit: Maximum number of versions to return

Returns:

  • []Settings: A slice of settings versions, newest first
  • error: Database error if the query fails

func (*Service) Save

func (s *Service) Save(key SettingsKey, value string) error

type Settings

type Settings struct {
	ID        int64       `gorm:"primaryKey;autoIncrement" json:"id"`
	Key       SettingsKey `json:"key"`
	Value     string      `json:"value"`
	Version   int         `json:"version"`
	CreatedAt int64       `json:"created_at"`
}

type SettingsKey

type SettingsKey string
const (
	SettingsKeyCustomRules          SettingsKey = "custom_rules"
	SettingsKeyIdleThreshold        SettingsKey = "idle_threshold"
	SettingsKeyHistoryRetention     SettingsKey = "history_retention"
	SettingsKeyDistractionAllowance SettingsKey = "distraction_allowance"
)

Jump to

Keyboard shortcuts

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