From 9785c7f80eb71d32b7981677e5b1a234e487ebdb Mon Sep 17 00:00:00 2001 From: "luis.scheurenbrand" Date: Wed, 10 Apr 2024 10:09:46 +0200 Subject: [PATCH] make total_size optional in pagination as off 2024-04-09, the artciles by sectoion endpoint might not return the total size if pagination isn't wanted --- src/api/common.rs | 2 +- src/routes/search.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/common.rs b/src/api/common.rs index ba8148e..9d5aad1 100644 --- a/src/api/common.rs +++ b/src/api/common.rs @@ -11,7 +11,7 @@ pub struct Articles { #[derive(Deserialize)] pub struct Pagination { pub size: u32, - pub total_size: u32, + pub total_size: Option, pub orderby: String, } diff --git a/src/routes/search.rs b/src/routes/search.rs index 9a0c0fa..6c161e8 100644 --- a/src/routes/search.rs +++ b/src/routes/search.rs @@ -91,7 +91,7 @@ fn render_articles( .as_ref() .map(|a| a.len() as u32) .unwrap_or(0); - let total = articles.pagination.total_size; + let total = articles.pagination.total_size.unwrap_or(0); let (has_prev, has_next) = (offset > 0, offset + count < total); let prev_page = if has_prev { let offset = offset.saturating_sub(steps); @@ -122,7 +122,7 @@ fn render_articles( li { a href=(&article.canonical_url) { (&article.title) } } } } - @if total != 0 { + @if has_prev || has_next { div.nav { a href=[prev_page] { "<" } ((offset + 1)) " to " ((offset + count)) " of " (total)