aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-25 11:55:42 -0600
committerColin Okay <okay@toyful.space>2022-02-25 11:55:42 -0600
commit8e615caf9725fac9f89c914f5aec2fdc852194d1 (patch)
tree2fbe9f674f100d3a0d7af7cdcebc02e3832a5402
parent53a36f70f9f3fe5226f6bd32f5f09ce60b1e013c (diff)
endpoint for returning only flagged oneliners
-rw-r--r--src/main.lisp18
1 files 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))