Class: SourceMonitor::Logs::TablePresenter::Row
- Inherits:
-
Object
- Object
- SourceMonitor::Logs::TablePresenter::Row
- Defined in:
- lib/source_monitor/logs/table_presenter.rb
Instance Method Summary collapse
- #adapter ⇒ Object
- #detail_path ⇒ Object
- #dom_id ⇒ Object
- #error_message ⇒ Object
- #failure? ⇒ Boolean
- #fetch? ⇒ Boolean
- #health_check? ⇒ Boolean
- #http_summary ⇒ Object
-
#initialize(entry, url_helpers) ⇒ Row
constructor
A new instance of Row.
- #metrics_summary ⇒ Object
- #primary_label ⇒ Object
- #primary_path ⇒ Object
- #scrape? ⇒ Boolean
- #source_label ⇒ Object
- #source_path ⇒ Object
- #started_at ⇒ Object
- #status_label ⇒ Object
- #status_variant ⇒ Object
- #success? ⇒ Boolean
- #type_label ⇒ Object
- #type_slug ⇒ Object
- #type_variant ⇒ Object
- #url_href ⇒ Object
- #url_label ⇒ Object
Constructor Details
#initialize(entry, url_helpers) ⇒ Row
Returns a new instance of Row.
7 8 9 10 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 7 def initialize(entry, url_helpers) @entry = entry @url_helpers = url_helpers end |
Instance Method Details
#adapter ⇒ Object
120 121 122 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 120 def adapter entry.scraper_adapter end |
#detail_path ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 109 def detail_path case entry.loggable when SourceMonitor::FetchLog url_helpers.fetch_log_path(entry.loggable) when SourceMonitor::ScrapeLog url_helpers.scrape_log_path(entry.loggable) else nil end end |
#dom_id ⇒ Object
12 13 14 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 12 def dom_id "#{type_slug}-#{entry.loggable_id}" end |
#error_message ⇒ Object
132 133 134 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 132 def entry. end |
#failure? ⇒ Boolean
128 129 130 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 128 def failure? !success? end |
#fetch? ⇒ Boolean
146 147 148 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 146 def fetch? entry.fetch? end |
#health_check? ⇒ Boolean
154 155 156 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 154 def health_check? entry.health_check? end |
#http_summary ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 88 def http_summary if fetch? entry.http_status.present? ? entry.http_status.to_s : "—" elsif scrape? parts = [] parts << entry.http_status.to_s if entry.http_status parts << entry.scraper_adapter if entry.scraper_adapter.present? parts.compact.join(" · ").presence || "—" else entry.http_status.present? ? entry.http_status.to_s : "—" end end |
#metrics_summary ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 101 def metrics_summary if fetch? "+#{entry.items_created.to_i} / ~#{entry.items_updated.to_i} / ✕#{entry.items_failed.to_i}" else entry.duration_ms.present? ? "#{entry.duration_ms} ms" : "—" end end |
#primary_label ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 48 def primary_label if scrape? entry.item&.title.presence || "(untitled)" else entry.source&.name end end |
#primary_path ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 56 def primary_path if scrape? && entry.item url_helpers.item_path(entry.item) elsif entry.source url_helpers.source_path(entry.source) end end |
#scrape? ⇒ Boolean
150 151 152 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 150 def scrape? entry.scrape? end |
#source_label ⇒ Object
80 81 82 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 80 def source_label entry.source&.name end |
#source_path ⇒ Object
84 85 86 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 84 def source_path url_helpers.source_path(entry.source) if entry.source end |
#started_at ⇒ Object
44 45 46 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 44 def started_at entry.started_at end |
#status_label ⇒ Object
36 37 38 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 36 def status_label entry.success? ? "Success" : "Failure" end |
#status_variant ⇒ Object
40 41 42 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 40 def status_variant entry.success? ? :success : :failure end |
#success? ⇒ Boolean
124 125 126 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 124 def success? entry.success? end |
#type_label ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 16 def type_label if fetch? "Fetch" elsif scrape? "Scrape" else "Health Check" end end |
#type_slug ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 136 def type_slug if fetch? "fetch" elsif scrape? "scrape" else "health-check" end end |
#type_variant ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 26 def type_variant if fetch? :fetch elsif scrape? :scrape else :health_check end end |
#url_href ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 72 def url_href if fetch? entry.source&.feed_url elsif scrape? entry.item&.url end end |
#url_label ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/source_monitor/logs/table_presenter.rb', line 64 def url_label if fetch? domain_from_feed_url elsif scrape? entry.item&.url end end |