Skip to content

Commit

Permalink
Fix how to determine last update time of the blog
Browse files Browse the repository at this point in the history
  • Loading branch information
hongquan committed Aug 31, 2023
1 parent ab2e580 commit 0237ecf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/front/views/feeds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn gen_atom_feeds(
links.push(LinkBuilder::default().rel("previous".to_string()).href(format!("{base_url}{url}")).build())
}
let entries: Vec<Entry> = posts.iter().map(|p| p.to_atom_entry(Some(&host))).collect();
let latest_post = stores::blog::get_latest_post(&db)
let latest_post = stores::blog::get_last_updated_post(&db)
.await
.map_err(PageError::EdgeDBQueryError)?;
let updated_at = latest_post
Expand Down
4 changes: 2 additions & 2 deletions src/stores/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ pub async fn get_next_post(created_at: EDatetime, cat_slug: Option<&str>, client
Ok(post)
}

pub async fn get_latest_post(client: &Client) -> Result<Option<MiniBlogPost>, Error> {
pub async fn get_last_updated_post(client: &Client) -> Result<Option<MiniBlogPost>, Error> {
let q = "
SELECT BlogPost {
id,
title,
slug,
created_at,
updated_at,
} FILTER .is_published = true ORDER BY .created_at DESC LIMIT 1";
} FILTER .is_published = true ORDER BY .updated_at DESC LIMIT 1";
tracing::debug!("To query: {}", q);
let post: Option<MiniBlogPost> = client.query_single(q, &()).await?;
Ok(post)
Expand Down

0 comments on commit 0237ecf

Please sign in to comment.