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
This commit is contained in:
parent
5f77b4cd4f
commit
16d81e8ccc
|
|
@ -216,7 +216,7 @@ This was the most challenging conversion due to complex ParenScript compilation
|
||||||
;; WRONG:
|
;; WRONG:
|
||||||
(push item *play-queue*)
|
(push item *play-queue*)
|
||||||
|
|
||||||
;; CORRECT (what we implemented):
|
;; CORRECT (what I implemented):
|
||||||
(setf (aref *play-queue* (ps:@ *play-queue* length)) item)
|
(setf (aref *play-queue* (ps:@ *play-queue* length)) item)
|
||||||
|
|
||||||
;; ALTERNATIVE (more idiomatic, could be used instead):
|
;; 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
|
*** Challenge 6: Icecast Listener Count Aggregation
|
||||||
*Problem:* Function only checked =/asteroid.mp3= mount point, missing listeners on =/asteroid.aac= and =/asteroid-low.mp3= streams.
|
*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
|
#+BEGIN_EXAMPLE
|
||||||
(let ((total-listeners 0))
|
(let ((total-listeners 0))
|
||||||
(dolist (mount '("/asteroid\\.mp3" "/asteroid\\.aac" "/asteroid-low\\.mp3"))
|
(dolist (mount '("/asteroid\\.mp3" "/asteroid\\.aac" "/asteroid-low\\.mp3"))
|
||||||
(when (find-mount mount xml-string)
|
(let ((match-pos (cl-ppcre:scan (format nil "<source mount=\"~a\">" mount) xml-string)))
|
||||||
(incf total-listeners (parse-listener-count mount xml-string))))
|
(when match-pos
|
||||||
|
(let* ((source-section (subseq xml-string match-pos ...))
|
||||||
|
(listenersp (cl-ppcre:all-matches "<listeners>" source-section)))
|
||||||
|
(when listenersp
|
||||||
|
(let ((count (parse-integer (cl-ppcre:regex-replace-all
|
||||||
|
".*<listeners>(.*?)</listeners>.*"
|
||||||
|
source-section "\\1")
|
||||||
|
:junk-allowed t)))
|
||||||
|
(incf total-listeners count)))))))
|
||||||
total-listeners)
|
total-listeners)
|
||||||
#+END_EXAMPLE
|
#+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
|
*** Success Metrics
|
||||||
- player.lisp compiles without errors
|
- player.lisp compiles without errors
|
||||||
- All player functionality works (play, pause, queue, playlists)
|
- All player functionality works (play, pause, queue, playlists)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue