File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed
chloria-backend/chloria-job/src
infrastructure/news_fetcher Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,11 @@ struct NewsResponseChannelItem {
36
36
37
37
pub ( crate ) struct YahooClient {
38
38
providers : Vec < String > ,
39
+ interval : i64 ,
39
40
}
40
41
41
42
impl YahooClient {
42
- pub ( crate ) fn new ( ) -> Self {
43
+ pub ( crate ) fn new ( interval : i64 ) -> Self {
43
44
Self {
44
45
// TODO: Find a better way to retrieve the list of providers
45
46
providers : vec ! [
@@ -742,6 +743,7 @@ impl YahooClient {
742
743
. iter ( )
743
744
. map ( |p| p. to_string ( ) )
744
745
. collect ( ) ,
746
+ interval,
745
747
}
746
748
}
747
749
@@ -767,7 +769,7 @@ impl YahooClient {
767
769
Some ( pub_date) => match DateTime :: parse_from_rfc2822 ( & pub_date) {
768
770
Ok ( published_time) => {
769
771
let published_time: DateTime < Local > = published_time. into ( ) ;
770
- if ( now - published_time) . num_days ( ) > 0 {
772
+ if ( now - published_time) . num_hours ( ) >= self . interval {
771
773
continue ;
772
774
}
773
775
Some ( published_time)
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ async fn main() -> Result<()> {
42
42
. collect :: < Vec < _ > > ( ) ;
43
43
let chloria_origin_bucket_name = env:: var ( "CHLORIA_ORIGIN_BUCKET_NAME" ) ?;
44
44
let chloria_case_permits_num = env:: var ( "CHLORIA_CASE_PERMITS_NUM" ) ?. parse :: < usize > ( ) . unwrap_or ( 10 ) ;
45
+ let chloria_job_interval = env:: var ( "CHLORIA_JOB_INTERVAL" ) ?. parse ( ) ?; // In hours
45
46
env_logger:: init_from_env ( Env :: new ( ) . filter ( "CHLORIA_LOG" ) ) ;
46
47
// Initialize infrastructure
47
48
let mut news_fetchers: Vec < Arc < dyn NewsFetcher > > = vec ! [ ] ;
@@ -52,7 +53,7 @@ async fn main() -> Result<()> {
52
53
}
53
54
}
54
55
if chloria_news_fetchers. contains ( & "yahoo" . to_string ( ) ) {
55
- let yahoo_client = YahooClient :: new ( ) ;
56
+ let yahoo_client = YahooClient :: new ( chloria_job_interval ) ;
56
57
news_fetchers. push ( Arc :: new ( yahoo_client) ) ;
57
58
}
58
59
let reqwest_tool = ReqwestTool :: new ( ) ;
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ services:
57
57
- CHLORIA_NEWS_FETCHERS=yahoo
58
58
- CHLORIA_ORIGIN_BUCKET_NAME=origin
59
59
- CHLORIA_CASE_PERMITS_NUM=10
60
+ - CHLORIA_JOB_INTERVAL=12
60
61
- CHLORIA_LOG=info
61
62
volumes :
62
63
- ../:/usr/src/chloria/
You can’t perform that action at this time.
0 commit comments