feat: persist settings and scores in SQLite database#7
Merged
Conversation
Add a persistence layer using rusqlite + dirs: - Database stored at `dirs::data_dir()/nback/nback.db` (e.g. ~/Library/Application Support/nback/nback.db on macOS) - Settings table: single-row, loaded at startup, saved whenever GameSettings resource changes (via PersistencePlugin) - Scores table: one row per completed game session with an auto-populated played_at timestamp - ScoreRecord gains a played_at field (ISO-8601 string) - On game end: score is inserted, full history reloaded from DB - On startup: settings and score history loaded from DB Dependencies added: rusqlite (bundled), dirs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Game settings and score history are now persisted in a SQLite database using
rusqlite(bundled) anddirsfor platform-appropriate storage paths.Database location
~/Library/Application Support/nback/nback.db~/.local/share/nback/nback.dbC:\Users\<user>\AppData\Roaming\nback\nback.dbFalls back to
./nback/nback.dbif no data directory is available.Schema
Behavior
PersistencePluginwatchesGameSettingsfor changes and saves to DB inPostUpdate(covers both menu edits and end-of-game difficulty adjustments)played_attimestamps are populated by SQLite)played_at: Stringfield (ISO-8601, set bydatetime('now')default)Dependencies added
rusqlite 0.35withbundledfeature (statically links SQLite)dirs 6.0for platform data directories