Class: SourceMonitor::SourceDetailsPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- SourceMonitor::SourceDetailsPresenter
- Defined in:
- app/presenters/source_monitor/source_details_presenter.rb
Constant Summary collapse
- DATE_FORMAT =
"%b %d, %Y %H:%M %Z"
Instance Method Summary collapse
- #adaptive_interval_label ⇒ Object
- #circuit_state_label ⇒ Object
- #details_hash ⇒ Object
- #fetch_interval_display ⇒ Object
- #formatted_last_fetched_at ⇒ Object
- #formatted_next_fetch_at ⇒ Object
Methods inherited from BasePresenter
Constructor Details
This class inherits a constructor from SourceMonitor::BasePresenter
Instance Method Details
#adaptive_interval_label ⇒ Object
21 22 23 |
# File 'app/presenters/source_monitor/source_details_presenter.rb', line 21 def adaptive_interval_label adaptive_fetching_enabled? ? "Auto" : "Fixed" end |
#circuit_state_label ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/presenters/source_monitor/source_details_presenter.rb', line 12 def circuit_state_label if fetch_circuit_open? until_time = fetch_circuit_until&.strftime(DATE_FORMAT) || "unknown" "Open until #{until_time}" else "Closed" end end |
#details_hash ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/presenters/source_monitor/source_details_presenter.rb', line 33 def details_hash { "Fetch interval" => fetch_interval_display, "Adaptive interval" => adaptive_interval_label, "Scraper" => scraper_adapter, "Feed content" => feed_content_readability_enabled? ? "Readability" : "Raw", "Active" => active? ? "Yes" : "No", "Scraping" => scraping_enabled? ? "Enabled" : "Disabled", "Auto scrape" => auto_scrape? ? "Enabled" : "Disabled", "Requires JS" => requires_javascript? ? "Yes" : "No", "Failure count" => failure_count, "Retry attempt" => fetch_retry_attempt, "Circuit state" => circuit_state_label, "Last error" => last_error.presence || "None", "Items count" => items_count, "Retention days" => items_retention_days || "\u2014", "Max items" => max_items || "\u2014" } end |
#fetch_interval_display ⇒ Object
7 8 9 10 |
# File 'app/presenters/source_monitor/source_details_presenter.rb', line 7 def fetch_interval_display hours = number_with_precision(fetch_interval_minutes / 60.0, precision: 2) "#{fetch_interval_minutes} minutes (~#{hours} hours)" end |
#formatted_last_fetched_at ⇒ Object
29 30 31 |
# File 'app/presenters/source_monitor/source_details_presenter.rb', line 29 def formatted_last_fetched_at (last_fetched_at) end |
#formatted_next_fetch_at ⇒ Object
25 26 27 |
# File 'app/presenters/source_monitor/source_details_presenter.rb', line 25 def formatted_next_fetch_at (next_fetch_at) end |