Browse Source

implement the 're-populate search DB' functionality (web.lisp).

This feature is part of the 'danger zone' section in the site's settings. This
feature clears the Meilisearch database (with this site's Archive Entries) and
re-populates it with the data from this website's (nera) database.
stable
Craig Oates 2 years ago
parent
commit
74a6507902
  1. 20
      src/web.lisp

20
src/web.lisp

@ -1485,6 +1485,26 @@
(format nil "~a"
(mito.dao.mixin:object-updated-at item))))))))))
(defroute ("/danger/repopulate-search-db" :method :POST) ()
(destructuring-bind
(&key authenticity-token &allow-other-keys)
(utils:request-params (lack.request:request-body-parameters ningle:*request*))
(cond ((not (string= authenticity-token (auth:csrf-token)))
`(,+forbidden+ (:content-type "text/plain") ("Denied")))
(t (hermetic:auth
(:administrator)
;; Authorised
(progn
(search:repopulate-database (nera:get-all-archive-entries))
(utils:set-alert
"Search database re-populated. Great Success!" "success")
(redirect "/site-settings"))
;; Not Authorised
(progn (utils:set-alert
"You are not authorised to use this feature."
"error")
(redirect "/login")))))))
;;
;; Error pages

Loading…
Cancel
Save