فهرست منبع

[back] Alpha-first category sorting. Fixes #6

Innokentiy Enikeev 4 سال پیش
والد
کامیت
7c40c77da1
2فایلهای تغییر یافته به همراه15 افزوده شده و 3 حذف شده
  1. 14 2
      back/db.lisp
  2. 1 1
      back/server.lisp

+ 14 - 2
back/db.lisp

@@ -228,9 +228,21 @@
            (type function +album<>+ +track<>+))
   (let ((albs (the fixnum (funcall +album<>+ (track-album a) (track-album b)))))
     (if (zerop albs)
-    (< (the fixnum (funcall +track<>+ a b)) 0)
+        (< (the fixnum (funcall +track<>+ a b)) 0)
         albs)))
 
+(defun slot< (a b)
+  (declare #.*standard-optimize-settings*
+	   (type simple-string a b))
+  (let ((aa (alpha-char-p (elt a 0)))
+	(ba (alpha-char-p (elt b 0))))
+    (cond
+      ((and aa ba) (string< a b))
+      (aa 0)
+      (ba)
+      (t (string< a b)))))
+
+
 (defun match-filter (data category filter)
   (declare #.*standard-optimize-settings*)
 
@@ -285,7 +297,7 @@
                                   (case category
                                     (album (if latest #'album-added> #'album<))
                                     (year #'<)
-                                    (t #'string<))
+                                    (t #'slot<))
                                   :key (case category
                                          (album nil)
                                          (t #'car))))

+ 1 - 1
back/server.lisp

@@ -117,7 +117,7 @@
                                     (year (parse-integer value :junk-allowed t))
                                     (otherwise value)))))
 
-(defparameter +max-limit+ 100)
+(defparameter +max-limit+ 10000)
 (defmacro with-category ((params category filter restrictions offset limit latest) &body body)
   (with-gensyms (query-string query-params)
     `(let ((,category (getsym ,params :category)))