only apply tag to rss

This commit is contained in:
slonkazoid 2024-05-02 20:09:28 +03:00
parent 457692f766
commit ad2a8c6ba4
Signed by: slonk
SSH key fingerprint: SHA256:tbZfJX4IOvZ0LGWOWu5Ijo8jfMPi78TU7x1VoEeCIjM
2 changed files with 6 additions and 21 deletions

View file

@ -112,7 +112,12 @@ async fn rss(
let posts = state
.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?;
let mut channel = ChannelBuilder::default();

View file

@ -250,26 +250,6 @@ impl PostManager {
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(
&self,
name: &str,