From a4486ad168eb332defc235bd2b984e549ec1e7f8 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Tue, 18 Oct 2022 20:34:00 +0100 Subject: [PATCH] add get older/newer archive-entries in nera package. I, also, change the order to 'created-at' for getting all archive-entries. --- src/nera.lisp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/nera.lisp b/src/nera.lisp index 321d489..68f8b46 100644 --- a/src/nera.lisp +++ b/src/nera.lisp @@ -45,7 +45,9 @@ #:latest-archive-editted-entries #:latest-editted-pages #:latest-storage-editted-files - #:update-single-nav-menu-item)) + #:update-single-nav-menu-item + #:get-newer-archive-entries + #:get-older-archive-entries)) (in-package #:nera-db) (defparameter *tables* '(user site-settings page storage-file archive-entry) @@ -327,7 +329,7 @@ slug is updated based on `NEW-FILE-NAME'." "Returns a list of all `ARCHIVE-ENTRY' entries in the database." (with-connection (db) (mito:select-dao 'archive:archive-entry - (sxql:order-by (:asc :title))))) + (sxql:order-by (:desc :created-at))))) (defun create-archive-entry (title search-id slug pub-month pub-year thumbnail-slug thumbnail-file-type keywords) @@ -386,3 +388,19 @@ An example of how to use this function is as follows (remove back-slashes): (mito:delete-dao (mito:find-dao 'archive:archive-entry :id id))) ((not id) (mito:delete-dao (mito:find-dao 'archive:archive-entry :slug slug)))))) + +(defun get-newer-archive-entries (id amount) + "Returns `AMOUNT' of `ARCHIVE-ENTRY' objects relative to `ID' in database." + (with-connection (db) + (mito:select-dao 'archive:archive-entry + (sxql:where (:> :id id)) + (sxql:order-by :id) + (sxql:limit amount)))) + +(defun get-older-archive-entries (id amount) + "Returns `AMOUNT' of `ARCHIVE-ENTRY' objects relative to `ID' in database." + (with-connection (db) + (mito:select-dao 'archive:archive-entry + (sxql:where (:< :id id)) + (sxql:order-by (:desc :id)) + (sxql:limit amount))))