main #1

Merged
heavyweaponsgal merged 5 commits from slonk/bingus-blog:main into main 2024-05-03 01:27:49 +03:00
2 changed files with 6 additions and 21 deletions
Showing only changes of commit ad2a8c6ba4 - Show all commits

View file

@ -112,7 +112,12 @@ async fn rss(
let posts = state let posts = state
.posts .posts
.get_max_n_posts_with_optional_tag_sorted(query.num_posts, query.tag.as_ref()) .get_all_posts_filtered(|metadata, _| {
!query
.tag
.as_ref()
.is_some_and(|tag| !metadata.tags.contains(tag))
})
.await?; .await?;
let mut channel = ChannelBuilder::default(); let mut channel = ChannelBuilder::default();

View file

@ -250,26 +250,6 @@ impl PostManager {
Ok(posts) Ok(posts)
} }
pub async fn get_max_n_posts_with_optional_tag_sorted(
&self,
n: Option<usize>,
tag: Option<&String>,
) -> Result<Vec<(PostMetadata, String, RenderStats)>, PostError> {
let mut posts = self
.get_all_posts_filtered(|metadata, _| {
!tag.is_some_and(|tag| !metadata.tags.contains(tag))
})
.await?;
posts.sort_unstable_by_key(|(metadata, ..)| metadata.modified_at.unwrap_or_default());
posts.sort_by_key(|(metadata, ..)| metadata.created_at.unwrap_or_default());
posts.reverse();
if let Some(n) = n {
posts.truncate(n);
}
Ok(posts)
}
pub async fn get_post( pub async fn get_post(
&self, &self,
name: &str, name: &str,