aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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))