fix(web/panettone): Hotfixes for full text search change

- Actually define *static-dir* at build time, to get the search.png in
  the search box
- Better logging for migration running at startup time
- Fix and-where to properly exclude nil clauses
- fix looking up build-time vars in the :build package

Change-Id: Ia2ef3b2715d4c2efb62bbb2c72084f0f0ad09562
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11325
Autosubmit: aspen <root@gws.fyi>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Aspen Smith 2024-03-31 16:06:50 -04:00 committed by clbot
parent efe7e8e63a
commit 1d1984e85f
3 changed files with 8 additions and 5 deletions

View file

@ -27,10 +27,11 @@ depot.nix.buildLisp.program {
(pkgs.writeText "build.lisp" '' (pkgs.writeText "build.lisp" ''
(defpackage build (defpackage build
(:use :cl :alexandria) (:use :cl :alexandria)
(:export :*migrations-dir*)) (:export :*migrations-dir* :*static-dir*))
(in-package :build) (in-package :build)
(declaim (optimize (safety 3))) (declaim (optimize (safety 3)))
(defvar *migrations-dir* "${./src/migrations}") (defvar *migrations-dir* "${./src/migrations}")
(defvar *static-dir* "${./src/static}")
'') '')
./src/util.lisp ./src/util.lisp
./src/css.lisp ./src/css.lisp

View file

@ -324,6 +324,7 @@ in the context of a database transaction and should perform the migration."
(defun migrate () (defun migrate ()
"Migrate the database, running all migrations that have not yet been run" "Migrate the database, running all migrations that have not yet been run"
(ensure-migrations-table) (ensure-migrations-table)
(format t "Running migrations from ~A...~%" *migrations-dir*)
(let* ((all-migrations (load-migrations)) (let* ((all-migrations (load-migrations))
(already-run (migrations-already-run)) (already-run (migrations-already-run))
(num-migrations-run 0)) (num-migrations-run 0))
@ -350,7 +351,7 @@ in the context of a database transaction and should perform the migration."
;; otherwise, run the migration ;; otherwise, run the migration
(run-migration migration)) (run-migration migration))
(incf num-migrations-run)) (incf num-migrations-run))
(format nil "Ran ~A migration~:P" num-migrations-run))) (format t "Ran ~A migration~:P~%" num-migrations-run)))
;;; ;;;
;;; Querying ;;; Querying

View file

@ -16,8 +16,9 @@ that it can be successfully decoded by the `BASE64' package"
(defun and-where (clauses) (defun and-where (clauses)
"Combine all non-nil clauses in CLAUSES into a single S-SQL WHERE form" "Combine all non-nil clauses in CLAUSES into a single S-SQL WHERE form"
(if (null clauses) t (let ((clauses (remove nil clauses)))
(reduce (lambda (x y) `(:and ,x ,y)) clauses))) (if (null clauses) t
(reduce (lambda (x y) `(:and ,x ,y)) clauses))))
(defun and-where* (&rest clauses) (defun and-where* (&rest clauses)
"Combine all non-nil clauses in CLAUSES into a single S-SQL WHERE form" "Combine all non-nil clauses in CLAUSES into a single S-SQL WHERE form"
@ -27,7 +28,7 @@ that it can be successfully decoded by the `BASE64' package"
(name value-if-not-in-build &optional (doc nil)) (name value-if-not-in-build &optional (doc nil))
`(defvar ,name `(defvar ,name
(or (when-let ((package (find-package :build))) (or (when-let ((package (find-package :build)))
(let ((sym (find-symbol ,(symbol-name name)))) (let ((sym (find-symbol ,(symbol-name name) package)))
(when (boundp sym) (symbol-value sym)))) (when (boundp sym) (symbol-value sym))))
,value-if-not-in-build) ,value-if-not-in-build)
,doc)) ,doc))