blob: 3e2837fda8bd4b2b0b3cbfc5dda68af4621892fc (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 | module StopAreaReferentialSyncsHelper
  def last_stop_area_ref_sync_message(stop_area_ref_sync)
    stop_area_ref_sync.stop_area_referential_sync_messages.last
  end
  def stop_area_referential_sync_created_at(stop_area_ref_sync)
    l(last_stop_area_ref_sync_message(stop_area_ref_sync).created_at, format: :short_with_time)
  end
  def stop_area_referential_sync_status(stop_area_ref_sync)
    status =  stop_area_ref_sync.status
    if %w[new pending].include? status
      content_tag :span, '', class: "fa fa-clock-o"
    else
      cls =''
      cls = 'success' if status == 'successful'
      cls = 'danger' if status == 'failed'
      content_tag :span, '', class: "fa fa-circle text-#{cls}"
    end
  end
  def stop_area_referential_sync_message(stop_area_ref_sync)
    last_stop_area_ref_sync_message = last_stop_area_ref_sync_message(stop_area_ref_sync)
    data = last_stop_area_ref_sync_message.message_attributes.symbolize_keys!
    data[:processing_time] = distance_of_time_in_words(data[:processing_time].to_i)
    t("stop_area_referential_sync.message.#{last_stop_area_ref_sync_message.message_key}", last_stop_area_ref_sync_message.message_attributes.symbolize_keys!).html_safe
  end
end
 |