Module: Content::RepositoriesHelper
- Defined in:
- app/helpers/content/repositories_helper.rb
Instance Method Summary collapse
- #last_publish(details) ⇒ Object
- #last_sync(details) ⇒ Object
- #sync_history_metrics(history) ⇒ Object
- #sync_history_status(history) ⇒ Object
- #sync_history_times(history) ⇒ Object
- #sync_status(repo) ⇒ Object
Instance Method Details
#last_publish(details) ⇒ Object
17 18 19 20 |
# File 'app/helpers/content/repositories_helper.rb', line 17 def last_publish details return '' unless details[:distributors] && details[:distributors].first && published = details[:distributors].first[:last_publish] "#{time_ago_in_words published} ago" rescue '' end |
#last_sync(details) ⇒ Object
22 23 24 25 |
# File 'app/helpers/content/repositories_helper.rb', line 22 def last_sync details return '' unless details[:importers] && details[:importers].first && synced = details[:importers].first[:last_sync] "#{time_ago_in_words synced} ago" rescue '' end |
#sync_history_metrics(history) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/helpers/content/repositories_helper.rb', line 37 def sync_history_metrics history return {} unless history && last = history.first { :updated => last[:updated_count], :removed => last[:removed_count], :added => last[:added_count] } end |
#sync_history_status(history) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/helpers/content/repositories_helper.rb', line 46 def sync_history_status history return {} unless history && last = history.first { 'result' => last[:result], 'message' => last[:error_message] || last['summary']['error'], 'completed' => ("#{time_ago_in_words(last[:completed])} ago" rescue '') } end |
#sync_history_times(history) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/content/repositories_helper.rb', line 27 def sync_history_times history return {} unless history && history.first && summary = history.first['summary'] return {} unless summary[:comps] { :comps => summary[:comps][:time_total_sec], :errata => summary[:errata][:errata_time_total_sec], :packages => summary[:packages][:time_total_sec] } end |
#sync_status(repo) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/helpers/content/repositories_helper.rb', line 4 def sync_status repo status = repo.sync_status status = if status && status.first status.first[:state] else details = repo.retrieve_with_details details[:importers][0][:last_sync] if details && details[:importers] && details[:importers][0] end "#{time_ago_in_words(status)} ago" rescue status rescue '-' end |