add publish log

This commit is contained in:
Denis-Cosmin Nutiu 2024-12-23 14:58:03 +02:00
parent 02ab5ecaa6
commit 1bd19eff20
2 changed files with 3 additions and 2 deletions

View file

@ -87,7 +87,8 @@ async fn main() -> Result<(), anyhow::Error> {
if news_post.is_complete() {
let title = news_post.title.clone().unwrap();
if redis_service.is_post_seen(&title).await {
redis_service.publish(news_post).await;
redis_service.publish(&news_post).await;
info!("Published {:?}", news_post);
redis_service.mark_post_seen(&title, 60 * 60 * 24 * 3).await;
};
}

View file

@ -41,7 +41,7 @@ impl RedisService {
}
/// Publishes the post to the redis stream.
pub async fn publish(&mut self, post: NewsPost) {
pub async fn publish(&mut self, post: &NewsPost) {
let serialized_post = serde_json::to_string(&post).unwrap();
let result = redis::cmd("XADD")
.arg(format!("posts:{}", self.stream_name))