From 16d81e8ccc46252da880c8cde17d619e0300c7f5 Mon Sep 17 00:00:00 2001 From: Glenn Thompson Date: Fri, 7 Nov 2025 16:12:04 +0300 Subject: [PATCH] Document frontend-partials.lisp changes in ParenScript experiment - Added details about listener count aggregation across all mount points - Documented stray ^ character fix - Documented error handler additions - Documented debug logging additions - Cross-referenced error variable removal to Challenge 3 --- docs/PARENSCRIPT-EXPERIMENT.org | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/PARENSCRIPT-EXPERIMENT.org b/docs/PARENSCRIPT-EXPERIMENT.org index eadec16..5d102c8 100644 --- a/docs/PARENSCRIPT-EXPERIMENT.org +++ b/docs/PARENSCRIPT-EXPERIMENT.org @@ -216,7 +216,7 @@ This was the most challenging conversion due to complex ParenScript compilation ;; WRONG: (push item *play-queue*) -;; CORRECT (what we implemented): +;; CORRECT (what I implemented): (setf (aref *play-queue* (ps:@ *play-queue* length)) item) ;; ALTERNATIVE (more idiomatic, could be used instead): @@ -302,15 +302,29 @@ This was the most challenging conversion due to complex ParenScript compilation *** Challenge 6: Icecast Listener Count Aggregation *Problem:* Function only checked =/asteroid.mp3= mount point, missing listeners on =/asteroid.aac= and =/asteroid-low.mp3= streams. -*Solution:* Loop through all three mount points and aggregate listener counts: +*Solution:* Modified =icecast-now-playing= function in =frontend-partials.lisp= to loop through all three mount points and aggregate listener counts: #+BEGIN_EXAMPLE (let ((total-listeners 0)) (dolist (mount '("/asteroid\\.mp3" "/asteroid\\.aac" "/asteroid-low\\.mp3")) - (when (find-mount mount xml-string) - (incf total-listeners (parse-listener-count mount xml-string)))) + (let ((match-pos (cl-ppcre:scan (format nil "" mount) xml-string))) + (when match-pos + (let* ((source-section (subseq xml-string match-pos ...)) + (listenersp (cl-ppcre:all-matches "" source-section))) + (when listenersp + (let ((count (parse-integer (cl-ppcre:regex-replace-all + ".*(.*?).*" + source-section "\\1") + :junk-allowed t))) + (incf total-listeners count))))))) total-listeners) #+END_EXAMPLE +*Additional Changes to frontend-partials.lisp:* +- Fixed stray =^= character in =(in-package :asteroid)= form +- Added error handler to =define-api asteroid/partial/now-playing= endpoint to catch errors gracefully +- Added debug logging to track Icecast stats fetching and parsing +- Removed problematic error variable usage in error handlers (see Challenge 3) + *** Success Metrics - player.lisp compiles without errors - All player functionality works (play, pause, queue, playlists)