From c27ecb9853c7f3b3eddd940a24ce8a91763a4ff3 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Fri, 30 Sep 2022 08:33:53 +0100 Subject: [PATCH] add get latest editted 'X' functions in nera package. These functions haven't not been used much so I don't know how reliable they are in their current forms. Expect some work needed on them in the future. --- src/nera.lisp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/nera.lisp b/src/nera.lisp index 62829d8..5f6b5f5 100644 --- a/src/nera.lisp +++ b/src/nera.lisp @@ -41,7 +41,10 @@ #:create-archive-entry #:get-archive-entry #:delete-archive-entry - #:update-archive-entry-property)) + #:update-archive-entry-property + #:latest-archive-editted-entries + #:latest-editted-pages + #:latest-storage-editted-files)) (in-package #:nera-db) (defparameter *tables* '(user site-settings page storage-file archive-entry) @@ -161,6 +164,17 @@ (mito:select-dao 'page (sxql:order-by (:asc :slug))))) +(defun latest-editted-pages (amount &optional reverse) + "Gets the latest `AMOUNT' of edited entries from the database. +`REVERSE' is an optional parameter which puts the most recently +editted article entry as the first item in the list.." + (with-connection (db) + (mito:select-dao 'pages:page + (sxql:limit amount) + (if reverse + (sxql:order-by (:desc 'pages::updated-at)) + (sxql:order-by 'pages::updated-at))))) + (defun create-page (title slug nav-menu can-delete) "Add a new `PAGE' to the database." (with-connection (db) @@ -258,6 +272,17 @@ (mito:find-dao 'files:storage-file :name filename) (mito:find-dao 'files:storage-file :slug slug)))) +(defun latest-storage-editted-files (amount &optional reverse) + "Gets the latest `AMOUNT' of edited entries from the database. +`REVERSE' is an optional parameter which puts the most recently +editted article entry as the first item in the list.." + (with-connection (db) + (mito:select-dao 'storage-file + (sxql:limit amount) + (if reverse + (sxql:order-by (:desc 'storage::updated-at)) + (sxql:order-by 'storage::updated-at))))) + (defun get-all-storage-files () "Returns a list of all `STORAGE-FILES' entries in the database." (with-connection (db) @@ -310,6 +335,17 @@ slug is updated based on `NEW-FILE-NAME'." (mito:find-dao 'archive:archive-entry :slug slug)) (t nil)))) +(defun latest-archive-editted-entries (amount &optional reverse) + "Gets the latest `AMOUNT' of edited entries from the database. +`REVERSE' is an optional parameter which puts the most recently +editted article entry as the first item in the list.." + (with-connection (db) + (mito:select-dao 'archive:archive-entry + (sxql:limit amount) + (if reverse + (sxql:order-by (:desc 'archive::updated-at)) + (sxql:order-by 'archive::updated-at))))) + (defun update-archive-entry-property (&key slug property value) "Updates an `ARCHIVE-ENTRY' entry in database. An example of how to use this function is as follows (remove back-slashes):