Browse Source

fix pagination error in /recipes?:page? route in web package.

The previous version was getting the total number of entries in the user_recipe
table when constructing the pagination data. This cause the pagination code to
generate the incorrect pagination controls in the HTML template. The new version
builds the pagination data based on what the total number of entries in the
user_recipe table for the current logged in user account.
unstable
Craig Oates 8 months ago
parent
commit
d9f52f22bc
  1. 6
      src/web.lisp

6
src/web.lisp

@ -967,11 +967,13 @@ UNSORTED ROUTES
;; Authorised
(handler-case
(let* ((user (auth:get-current-user))
(page-size 1)
(page-size 100)
(pagination (pagination:make-pagination
:page (read-from-string page)
:page-size page-size
:nb-elements (db:get-table-count 'models:page))))
:nb-elements
(length (db:get-user-recipes
(models::account-account-id user))))))
(when (> (gethash :page pagination) (gethash :nb-pages pagination))
(throw-code +not-found+))
(render #P"recipes-index.html"

Loading…
Cancel
Save