mail based rss feed aggregator
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

reset the cooldown after successful fetching of a feed

ollie aa8d83c4 a30d61c8

+21 -4
+6
src/eater/feed/rss.gleam
··· 115 115 _ -> Location(..location, skip_n_times: 0) 116 116 } 117 117 } 118 + 119 + /// resets the cooldown to 0 0 120 + /// 121 + pub fn reset_cooldown(location: Location) { 122 + Location(..location, skip_n_times: 0, failed_n_times: 0) 123 + }
+15 -4
src/eater/fetcher.gleam
··· 366 366 woof.field("reason", "No sender is subscribed"), 367 367 ]) 368 368 [_, ..] -> { 369 - let handled = handle_feed(state.feed, state) 369 + let handled = handle_feed(state, state.feed) 370 370 case handled { 371 371 Ok(_) -> Nil 372 372 Error(error) -> ··· 401 401 /// handles the failure cases and incrementsthe feed's cooldown accordingly 402 402 /// 403 403 fn handle_feed( 404 - location: rss.Location, 405 404 state: State, 405 + location: rss.Location, 406 406 ) -> Result(Nil, HandleFeedError) { 407 407 let feed = fetch_feed(location) 408 408 ··· 418 418 in: state.registry, 419 419 ) 420 420 }) 421 - // TODO: update feed cooldown in database if its not skip_n_times = 0 && failed_n_times = 0 422 421 423 - Ok(Nil) 422 + case location.failed_n_times != 0 || location.skip_n_times != 0 { 423 + True -> 424 + rss.reset_cooldown(location) 425 + |> database.update_feed_cooldown(state.database) 426 + |> result.map_error(fn(error) { 427 + log(woof.Error, "Failed to reset feed cooldown", [ 428 + woof.field("details", string.inspect(error)), 429 + ]) 430 + }) 431 + |> result.unwrap(Nil) 432 + False -> Nil 433 + } 434 + |> Ok 424 435 } 425 436 Error(OnCooldown) -> 426 437 rss.cooldown(location)