Comments management
Some checks failed
Rust / Rustfmt (push) Has been cancelled
Rust / Clippy (push) Has been cancelled
Rust / Code coverage (push) Has been cancelled
Rust / Test (push) Has been cancelled

This commit is contained in:
Alphonse Paix
2025-10-03 21:12:17 +02:00
parent af9cbdcafb
commit 50a7af2b06
7 changed files with 228 additions and 25 deletions

View File

@@ -1,9 +1,9 @@
use crate::routes::get_max_page;
use crate::routes::{COMMENTS_PER_PAGE, get_max_page};
use crate::templates::PostsPageDashboardTemplate;
use crate::{
domain::PostEntry,
routes::{
AppError, Path, Query, fetch_comments_count, fetch_comments_page, get_comments_page_count,
AppError, Path, Query, get_comments_count_for_post, get_comments_page_for_post,
not_found_html,
},
startup::AppState,
@@ -144,11 +144,11 @@ pub async fn see_post(
.to_html()
.context("Could not render markdown with extension.")?;
let current_page = 1;
let comments_count = fetch_comments_count(&connection_pool, post_id)
let comments_count = get_comments_count_for_post(&connection_pool, post_id)
.await
.context("Could not fetch comment count")?;
let max_page = get_comments_page_count(comments_count);
let comments = fetch_comments_page(&connection_pool, post_id, 1)
let max_page = get_max_page(comments_count, COMMENTS_PER_PAGE);
let comments = get_comments_page_for_post(&connection_pool, post_id, 1)
.await
.context("Failed to fetch latest comments")?;
let template = HtmlTemplate(PostTemplate {