Browse Source

wiggly donkers

master
eta 11 months ago
parent
commit
2bd1e77fc8
  1. 32
      scrobble.lisp

32
scrobble.lisp

@ -68,10 +68,12 @@ @@ -68,10 +68,12 @@
(defun get-all-artists ()
(tq::with-prepared-statement
(get "SELECT DISTINCT artist FROM plays ORDER BY artist ASC")
(get "SELECT artist, COUNT(*) FROM plays GROUP BY artist ORDER BY artist ASC")
(loop
while (sqlite:step-statement get)
collect (sqlite:statement-column-value get 0))))
collect (cons
(sqlite:statement-column-value get 0)
(sqlite:statement-column-value get 1)))))
(defmacro cassoc (item alist)
`(cdr (assoc ,item ,alist)))
@ -154,19 +156,35 @@ @@ -154,19 +156,35 @@
(who:esc artist)
" — "
(who:esc title)))))
(let ((artists (get-all-artists)))
(let* ((artists (get-all-artists))
(len (length artists)))
(who:with-html-output (*standard-output*)
(:p
:class "detail"
"Artists ("
(:strong
(who:esc (princ-to-string (length artists))))
"): "
(who:esc (format nil "~{~A~^ · ~}" artists)))))))
(who:fmt "~D" len))
" total): "
(loop
for (artist . count) in artists
for i from 1
when (> count 10)
do (princ "<b>")
when (> count 100)
do (princ "<span style=\"color: #6b55d4;\">")
do (who:esc artist)
when (> count 10)
do (princ "</b>")
when (> count 100)
do (princ "</span>")
unless (eql len i)
do (princ " &middot; ")
))))))
(defun main ()
(tq::connect-database)
(hunchentoot:start
(make-instance 'hunchentoot:easy-acceptor
:address "::"
:port 4242))
(sb-impl::toplevel-repl nil))
(loop (sleep 1)))

Loading…
Cancel
Save