From 1bd19eff20a188016ab25b37bd3cccdb8d4948e1 Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Mon, 23 Dec 2024 14:58:03 +0200 Subject: [PATCH] add publish log --- scrapper/src/main.rs | 3 ++- scrapper/src/redis.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scrapper/src/main.rs b/scrapper/src/main.rs index 3696028..1509203 100644 --- a/scrapper/src/main.rs +++ b/scrapper/src/main.rs @@ -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; }; } diff --git a/scrapper/src/redis.rs b/scrapper/src/redis.rs index aaf53aa..eb41133 100644 --- a/scrapper/src/redis.rs +++ b/scrapper/src/redis.rs @@ -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))