Implement RADIANCE database integration

- Add database collections for tracks and playlists
- Configure proper RADIANCE field types (:text, :integer)
- Add r-data-model dependency for database backend
- Fix build-executable.lisp RADIANCE environment handling
- Update admin dashboard to show real database connection status
- Database now initializes successfully on server startup
This commit is contained in:
Glenn Thompson 2025-09-11 08:54:12 +03:00
parent 1994e3b515
commit 1076582fb4
3 changed files with 40 additions and 4 deletions

View File

@ -14,7 +14,8 @@
:spinneret
:cl-json
:dexador
:lass)
:lass
:r-data-model)
:pathname "./"
:components ((:file "app-utils")
(:file "module")

View File

@ -14,6 +14,32 @@
;; Configuration
(defparameter *server-port* 8080)
(defparameter *music-library-path*
(merge-pathnames "music/library/"
(asdf:system-source-directory :asteroid)))
(defparameter *supported-formats* '("mp3" "flac" "ogg" "wav"))
;; Database initialization - must be in db:connected trigger
(define-trigger db:connected ()
"Initialize database collections when database connects"
(unless (db:collection-exists-p "tracks")
(db:create "tracks" '((title :text)
(artist :text)
(album :text)
(duration :integer)
(file-path :text)
(format :text)
(bitrate :integer)
(added-date :integer)
(play-count :integer))))
(unless (db:collection-exists-p "playlists")
(db:create "playlists" '((name :text)
(description :text)
(created-date :integer)
(track-ids :text))))
(format t "Database collections initialized~%"))
;; Define CLIP attribute processor for data-text
(clip:define-attribute-processor data-text (node value)
@ -67,7 +93,9 @@
(plump:parse (alexandria:read-file-into-string template-path))
:title "Asteroid Radio - Admin Dashboard"
:server-status "🟢 Running"
:database-status "🟡 Not Connected"
:database-status (handler-case
(if (db:connected-p) "🟢 Connected" "🔴 Disconnected")
(error () "🔴 No Database Backend"))
:liquidsoap-status "🔴 Not Running"
:icecast-status "🔴 Not Running")))

View File

@ -6,8 +6,15 @@
;; Build script for creating asteroid executable using save-lisp-and-die
;; ASDF will automatically find the project via source-registry.conf
;; Load the system
(ql:quickload :asteroid)
;; Load RADIANCE first, then handle environment
(ql:quickload :radiance)
;; Load the system with RADIANCE environment handling
(handler-bind ((radiance-core:environment-not-set
(lambda (c)
(declare (ignore c))
(invoke-restart 'continue))))
(ql:quickload :asteroid))
;; Define the main function for the executable
(defun main ()