database

package
v0.0.0-...-3397cd8 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the database connection

func Get

func Get() *sql.DB

Get returns the database connection

func GetLatestEventTimestamp

func GetLatestEventTimestamp() (int64, error)

GetLatestEventTimestamp returns a unix timestamp to resume historical fetch from. Uses MAX(first_seen_at) from torrents (indexed, fast) minus a 1-hour buffer to account for clock skew between local time and relay event timestamps, and to catch any late-arriving events. This means a small overlap is re-processed on restart, which is safe since the deduplicator handles duplicates.

func GetRecentTorrents

func GetRecentTorrents(limit int) ([]map[string]interface{}, error)

GetRecentTorrents returns the most recent torrents

func GetSetting

func GetSetting(key string) (string, error)

GetSetting retrieves a setting value by key

func GetStats

func GetStats() (map[string]interface{}, error)

GetStats returns database statistics

func GetTorrentsPerDay

func GetTorrentsPerDay(days int) ([]map[string]interface{}, error)

GetTorrentsPerDay returns torrent counts for the last N days

func Init

func Init(dbPath string) error

Init initializes the SQLite database connection and runs schema

func IsSetupCompleted

func IsSetupCompleted() bool

IsSetupCompleted checks if the setup wizard has been completed

func LogActivity

func LogActivity(eventType string, details string) error

LogActivity logs an activity event

func SeedDefaultRelays

func SeedDefaultRelays(relays []RelayConfig) error

SeedDefaultRelays inserts default relays if the relays table is empty

func SeedDefaultWhitelist

func SeedDefaultWhitelist() error

SeedDefaultWhitelist adds default trusted users to the whitelist

func SetSetting

func SetSetting(key, value string) error

SetSetting sets a setting value

Types

type RelayConfig

type RelayConfig struct {
	URL     string
	Name    string
	Preset  string
	Enabled bool
}

RelayConfig represents a relay configuration for seeding

type WhitelistEntry

type WhitelistEntry struct {
	Npub  string
	Alias string
	Notes string
}

WhitelistEntry represents a default whitelist entry

Jump to

Keyboard shortcuts

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