From 8e615caf9725fac9f89c914f5aec2fdc852194d1 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 25 Feb 2022 11:55:42 -0600 Subject: endpoint for returning only flagged oneliners --- src/main.lisp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.lisp b/src/main.lisp index f42b1f0..e31aa76 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -99,7 +99,7 @@ ((oneliner :accessor oneliner :initarg :oneliner - :initform (error "Onliner required")) + :initform (error "Oneliner required")) (runstyle :accessor oneliner-runstyle :initarg :runstyle @@ -146,7 +146,7 @@ (flagged-by :accessor flagged-by :initform nil - :documentation "NIL or :anonymous or a CONTRIBUTOR object.") + :documentation "NIL or a CONTRIBUTOR object.") (lockedp :accessor lockedp :initform nil @@ -381,6 +381,14 @@ ;;; NONTRANSACTIONAL DATABASE QUERIES +(defun flagged-oneliners (&optional limit) + (loop + for idx from 0 + for ol in (db:store-objects-with-class 'oneliner) + while (or (not limit) (< idx limit)) + when (flagged-by ol) + collect ol)) + (defun oneliners-with-all-tags (tags) (reduce #'intersection (mapcar #'oneliners-by-tag tags))) @@ -582,6 +590,12 @@ admin privileges are allowed to perform this action." (unflag-oneliner entry)) "true") +(defendpoint* :get "/oneliners/all-flagged" ((limit an-int)) + () + "A search endpoint returning all of the flagged oneliners. If LIMIT + is present, only that many are returned." + (to-json (list :oneliners (flagged-oneliners limit)))) + (defendpoint* :get "/oneliners" ((tags a-csl) (limit an-int) (notflagged a-boolean)) -- cgit v1.2.3