<commit_before>!!! 5
- nav = render_haml('_nav.haml', self)
- head = render_haml('_head.haml', self)
- foot = render_haml('_foot.haml', self)
- check_path_escaped = URI.escape(@entity, ' #&;/=?') << '/' << URI.escape(@check, ' #&;/=?')
- current_time = Time.now.to_i
%html
  %head
    %title Flapjack - Check: #{@entity}:#{@check}
    = head
  %body
    %div#wrap
      %div{:class => "container"}
        %div{:class => "page-header"}
          = nav
          %h2 #{@check} on #{@entity}
        %h3 State: #{@check_state ? @check_state.upcase : ''}
        - if (['warning', 'critical', 'unknown'].include?(@check_state) and !@current_scheduled_maintenance)
          %form{:action => "/acknowledgements/#{check_path_escaped}", :method => "post", :class => "form-inline"}
            %input{:type => 'hidden', :name => 'acknowledgement_id', :value => "#{@acknowledgement_id}"}
            %input{:type => 'submit', :value => @current_unscheduled_maintenance ? 'Replace acknowledgment' : 'Acknowledge', :class => 'button'}
            with
            %label{:for => 'summary'}
              summary:
            %input{:type => 'text', :name => 'summary', :value => ''}
            %label{:for => 'duration'}
              duration:
            %input{:type => 'text', :name => 'duration', :value => ''}
              e.g. "5 hours"
        - if @current_unscheduled_maintenance
          %h3 (Acknowledged - #{@current_unscheduled_maintenance[:summary]})
          - start  = Time.at(@current_unscheduled_maintenance[:start_time])
          - finish = Time.at(@current_unscheduled_maintenance[:start_time] + @current_unscheduled_maintenance[:duration])
          - remain = time_period_in_words( (finish - current_time).ceil )
          %p #{start} -&gt; #{finish} (#{remain} remaining)
          %form{:action => "/end_unscheduled_maintenance/#{check_path_escaped}", :method => "post"}
            %p
              %input{:type => 'submit', :value => 'End Unscheduled Maintenance (Unacknowledge)', :class => 'button'}
        - if @current_scheduled_maintenance
          %h4 (Scheduled Maintenance - #{@current_scheduled_maintenance[:summary]})
          - start  = Time.at(@current_scheduled_maintenance[:start_time])
          - finish = Time.at(@current_scheduled_maintenance[:start_time] + @current_scheduled_maintenance[:duration])
          - remain = time_period_in_words( (finish - current_time).ceil )
          %p #{start} -&gt; #{finish} (#{remain} remaining)
        %h3 Output: #{@check_summary}
        %p #{@check_details}
        %table{:class => "table table-hover table-condensed"}
          %tr
            %td Last state change:
            %td #{relative_time_ago(Time.at(@check_last_change.to_i))} ago
            %td #{Time.at(@check_last_change.to_i)}
            %td &nbsp;
          %tr
            %td Last update:
            %td #{relative_time_ago(Time.at(@check_last_update.to_i))} ago
            %td #{Time.at(@check_last_update.to_i)}
            %td &nbsp;
          - last_critical = nil
          - if @last_notifications[:critical] && @last_notifications[:critical][:timestamp]
            - t = Time.at(@last_notifications[:critical][:timestamp])
            - last_critical = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:critical][:summary]}
          %tr
            %td Last critical notification:
            %td= last_critical ? last_critical[:relative] : 'never'
            %td= last_critical ? last_critical[:time] : ''
            %td= last_critical ? last_critical[:summary] : ''

          - last_warning = nil
          - if @last_notifications[:warning] && @last_notifications[:warning][:timestamp]
            - t = Time.at(@last_notifications[:warning][:timestamp])
            - last_warning = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:warning][:summary]}
          %tr
            %td Last warning notification:
            %td= last_warning ? last_warning[:relative] : 'never'
            %td= last_warning ? last_warning[:time] : ''
            %td= last_warning ? last_warning[:summary] : ''

          - last_unknown = nil
          - if @last_notifications[:unknown] && @last_notifications[:unknown][:timestamp]
            - t = Time.at(@last_notifications[:unknown][:timestamp])
            - last_unknown = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:unknown][:summary]}
          %tr
            %td Last unknown notification:
            %td= last_unknown ? last_unknown[:relative] : 'never'
            %td= last_unknown ? last_unknown[:time] : ''
            %td= last_unknown ? last_unknown[:summary] : ''

          - last_recovery = nil
          - if @last_notifications[:recovery] && @last_notifications[:recovery][:timestamp]
            - t = Time.at(@last_notifications[:recovery][:timestamp])
            - last_recovery = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:recovery][:summary]}
          %tr
            %td Last recovery notification:
            %td= last_recovery ? last_recovery[:relative] : 'never'
            %td= last_recovery ? last_recovery[:time] : ''
            %td= last_recovery ? last_recovery[:summary] : ''

          - last_ack = nil
          - if @last_notifications[:acknowledgement] && @last_notifications[:acknowledgement][:timestamp]
            - t = Time.at(@last_notifications[:acknowledgement][:timestamp])
            - last_ack = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:acknowledgement][:summary]}
          %tr
            %td Last acknowledgement notification:
            %td= last_ack ? last_ack[:relative] : 'never'
            %td= last_ack ? last_ack[:time] : ''
            %td= last_ack ? last_ack[:summary] : ''

        %h3 Scheduled Maintenance Periods
        - if @scheduled_maintenances && !@scheduled_maintenances.empty?
          %table{:class => "table table-bordered table-hover table-condensed"}
            %tr
              %th Start
              %th End
              %th Duration
              %th Summary
              %th Actions
            - @scheduled_maintenances.sort_by {|s| s[:start_time]}.each do |scheduled_maintenance|
              - start_time = scheduled_maintenance[:start_time]
              - end_time   = scheduled_maintenance[:end_time]
              - duration   = scheduled_maintenance[:duration]
              - summary    = scheduled_maintenance[:summary]
              %tr
                %td= Time.at(start_time).to_s
                %td= Time.at(end_time).to_s
                %td= ChronicDuration.output(duration)
                %td= summary
                %td
                  - if end_time > current_time
                    - label = (start_time > current_time) ? 'Delete' : 'End Now'
                    %form{ :action => "/scheduled_maintenances/#{check_path_escaped}", :method => "post"}
                      %input{:type => 'hidden', :name => '_method', :value => 'delete'}
                      %input{:type => 'hidden', :name => 'start_time', :value => start_time}
                      %input{:type => 'submit', :value => label, :class => 'button'}
        - else
          %p No maintenance is scheduled
        %h4 Add Scheduled Maintenance
        %form{:action => "/scheduled_maintenances/#{check_path_escaped}", :method => "post", :class => "form-horizontal"}
          %div{:class => "control-group"}
            %label{:class => "control-label", :for => 'start_time'} Start time:
            %div{:class => "controls"}
              %input{:type => 'text', :name => 'start_time', :class => 'text', :size => '20', :maxlength => '80'}
              e.g. "today 4pm", "two hours hence", "friday 2pm", "2012-01-28 13:00"
          %div{:class => "control-group"}
            %label{:class => "control-label", :for => 'duration'} Duration:
            %div{:class => "controls"}
              %input{:type => 'text', :name => 'duration', :class => 'text', :size => '20', :maxlength => '80'}
              e.g. "1 hour", "2:30:00", "three days", etc
          %div{:class => "control-group"}
            %label{:class => "control-label", :for => 'summary'} Summary:
            %div{:class => "controls"}
              %input{:type => 'text', :name => 'summary', :class => 'text', :size => '80', :maxlength => '160'}
          %div{:class => "control-group"}
            %div{:class => "controls"}
              %input{:type => 'submit', :value => 'Save', :class => 'button'}
        %p Times given will be interpreted in the local timezone of  #{local_timezone}

        - if @state_changes && !@state_changes.empty?
          %h3 Recent state changes
          %table{:class => "table table-bordered table-hover table-condensed"}
            %tr
              %th Timestamp
              %th State
              %th Summary
            - @state_changes.each do |sc|
              %tr
                %td= Time.at(sc[:timestamp]).to_s
                %td= sc[:state]
                %td= sc[:summary]

        %h3 Contacts
        - if @contacts && !@contacts.empty?
          %table{:class => "table table-bordered table-hover table-condensed"}
            %tr
              %th Name
              %th Media
            - @contacts.sort_by {|c| [c.first_name, c.last_name] }.each do |contact|
              %tr
                %td
                  - link = "/contacts/#{contact.id}"
                  %a(title='contact details' href=link) #{contact.name}
                %td
                  - if contact.media && !contact.media.empty?
                    %p= contact.media.keys.collect(&:capitalize).join(", ")
                  - else
                    %p No media
        - else
          %p No contacts
      %div#push
    %div#footer
      = foot

<commit_msg>bugfix for time in check template<commit_after>!!! 5
- nav = render_haml('_nav.haml', self)
- head = render_haml('_head.haml', self)
- foot = render_haml('_foot.haml', self)
- check_path_escaped = URI.escape(@entity, ' #&;/=?') << '/' << URI.escape(@check, ' #&;/=?')
- current_time = Time.now
%html
  %head
    %title Flapjack - Check: #{@entity}:#{@check}
    = head
  %body
    %div#wrap
      %div{:class => "container"}
        %div{:class => "page-header"}
          = nav
          %h2 #{@check} on #{@entity}
        %h3 State: #{@check_state ? @check_state.upcase : ''}
        - if (['warning', 'critical', 'unknown'].include?(@check_state) and !@current_scheduled_maintenance)
          %form{:action => "/acknowledgements/#{check_path_escaped}", :method => "post", :class => "form-inline"}
            %input{:type => 'hidden', :name => 'acknowledgement_id', :value => "#{@acknowledgement_id}"}
            %input{:type => 'submit', :value => @current_unscheduled_maintenance ? 'Replace acknowledgment' : 'Acknowledge', :class => 'button'}
            with
            %label{:for => 'summary'}
              summary:
            %input{:type => 'text', :name => 'summary', :value => ''}
            %label{:for => 'duration'}
              duration:
            %input{:type => 'text', :name => 'duration', :value => ''}
              e.g. "5 hours"
        - if @current_unscheduled_maintenance
          %h3 (Acknowledged - #{@current_unscheduled_maintenance[:summary]})
          - start  = Time.at(@current_unscheduled_maintenance[:start_time])
          - finish = Time.at(@current_unscheduled_maintenance[:start_time] + @current_unscheduled_maintenance[:duration])
          - remain = time_period_in_words( (finish - current_time).ceil )
          %p #{start} -&gt; #{finish} (#{remain} remaining)
          %form{:action => "/end_unscheduled_maintenance/#{check_path_escaped}", :method => "post"}
            %p
              %input{:type => 'submit', :value => 'End Unscheduled Maintenance (Unacknowledge)', :class => 'button'}
        - if @current_scheduled_maintenance
          %h4 (Scheduled Maintenance - #{@current_scheduled_maintenance[:summary]})
          - start  = Time.at(@current_scheduled_maintenance[:start_time])
          - finish = Time.at(@current_scheduled_maintenance[:start_time] + @current_scheduled_maintenance[:duration])
          - remain = time_period_in_words( (finish - current_time).ceil )
          %p #{start} -&gt; #{finish} (#{remain} remaining)
        %h3 Output: #{@check_summary}
        %p #{@check_details}
        %table{:class => "table table-hover table-condensed"}
          %tr
            %td Last state change:
            %td #{relative_time_ago(Time.at(@check_last_change.to_i))} ago
            %td #{Time.at(@check_last_change.to_i)}
            %td &nbsp;
          %tr
            %td Last update:
            %td #{relative_time_ago(Time.at(@check_last_update.to_i))} ago
            %td #{Time.at(@check_last_update.to_i)}
            %td &nbsp;
          - last_critical = nil
          - if @last_notifications[:critical] && @last_notifications[:critical][:timestamp]
            - t = Time.at(@last_notifications[:critical][:timestamp])
            - last_critical = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:critical][:summary]}
          %tr
            %td Last critical notification:
            %td= last_critical ? last_critical[:relative] : 'never'
            %td= last_critical ? last_critical[:time] : ''
            %td= last_critical ? last_critical[:summary] : ''

          - last_warning = nil
          - if @last_notifications[:warning] && @last_notifications[:warning][:timestamp]
            - t = Time.at(@last_notifications[:warning][:timestamp])
            - last_warning = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:warning][:summary]}
          %tr
            %td Last warning notification:
            %td= last_warning ? last_warning[:relative] : 'never'
            %td= last_warning ? last_warning[:time] : ''
            %td= last_warning ? last_warning[:summary] : ''

          - last_unknown = nil
          - if @last_notifications[:unknown] && @last_notifications[:unknown][:timestamp]
            - t = Time.at(@last_notifications[:unknown][:timestamp])
            - last_unknown = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:unknown][:summary]}
          %tr
            %td Last unknown notification:
            %td= last_unknown ? last_unknown[:relative] : 'never'
            %td= last_unknown ? last_unknown[:time] : ''
            %td= last_unknown ? last_unknown[:summary] : ''

          - last_recovery = nil
          - if @last_notifications[:recovery] && @last_notifications[:recovery][:timestamp]
            - t = Time.at(@last_notifications[:recovery][:timestamp])
            - last_recovery = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:recovery][:summary]}
          %tr
            %td Last recovery notification:
            %td= last_recovery ? last_recovery[:relative] : 'never'
            %td= last_recovery ? last_recovery[:time] : ''
            %td= last_recovery ? last_recovery[:summary] : ''

          - last_ack = nil
          - if @last_notifications[:acknowledgement] && @last_notifications[:acknowledgement][:timestamp]
            - t = Time.at(@last_notifications[:acknowledgement][:timestamp])
            - last_ack = {:time => t.to_s, :relative => relative_time_ago(t) + " ago", :summary => @last_notifications[:acknowledgement][:summary]}
          %tr
            %td Last acknowledgement notification:
            %td= last_ack ? last_ack[:relative] : 'never'
            %td= last_ack ? last_ack[:time] : ''
            %td= last_ack ? last_ack[:summary] : ''

        %h3 Scheduled Maintenance Periods
        - if @scheduled_maintenances && !@scheduled_maintenances.empty?
          %table{:class => "table table-bordered table-hover table-condensed"}
            %tr
              %th Start
              %th End
              %th Duration
              %th Summary
              %th Actions
            - @scheduled_maintenances.sort_by {|s| s[:start_time]}.each do |scheduled_maintenance|
              - start_time = scheduled_maintenance[:start_time]
              - end_time   = scheduled_maintenance[:end_time]
              - duration   = scheduled_maintenance[:duration]
              - summary    = scheduled_maintenance[:summary]
              %tr
                %td= Time.at(start_time).to_s
                %td= Time.at(end_time).to_s
                %td= ChronicDuration.output(duration)
                %td= summary
                %td
                  - if end_time > current_time.to_i
                    - label = (start_time > current_time.to_i) ? 'Delete' : 'End Now'
                    %form{ :action => "/scheduled_maintenances/#{check_path_escaped}", :method => "post"}
                      %input{:type => 'hidden', :name => '_method', :value => 'delete'}
                      %input{:type => 'hidden', :name => 'start_time', :value => start_time}
                      %input{:type => 'submit', :value => label, :class => 'button'}
        - else
          %p No maintenance is scheduled
        %h4 Add Scheduled Maintenance
        %form{:action => "/scheduled_maintenances/#{check_path_escaped}", :method => "post", :class => "form-horizontal"}
          %div{:class => "control-group"}
            %label{:class => "control-label", :for => 'start_time'} Start time:
            %div{:class => "controls"}
              %input{:type => 'text', :name => 'start_time', :class => 'text', :size => '20', :maxlength => '80'}
              e.g. "today 4pm", "two hours hence", "friday 2pm", "2012-01-28 13:00"
          %div{:class => "control-group"}
            %label{:class => "control-label", :for => 'duration'} Duration:
            %div{:class => "controls"}
              %input{:type => 'text', :name => 'duration', :class => 'text', :size => '20', :maxlength => '80'}
              e.g. "1 hour", "2:30:00", "three days", etc
          %div{:class => "control-group"}
            %label{:class => "control-label", :for => 'summary'} Summary:
            %div{:class => "controls"}
              %input{:type => 'text', :name => 'summary', :class => 'text', :size => '80', :maxlength => '160'}
          %div{:class => "control-group"}
            %div{:class => "controls"}
              %input{:type => 'submit', :value => 'Save', :class => 'button'}
        %p Times given will be interpreted in the local timezone of  #{local_timezone}

        - if @state_changes && !@state_changes.empty?
          %h3 Recent state changes
          %table{:class => "table table-bordered table-hover table-condensed"}
            %tr
              %th Timestamp
              %th State
              %th Summary
            - @state_changes.each do |sc|
              %tr
                %td= Time.at(sc[:timestamp]).to_s
                %td= sc[:state]
                %td= sc[:summary]

        %h3 Contacts
        - if @contacts && !@contacts.empty?
          %table{:class => "table table-bordered table-hover table-condensed"}
            %tr
              %th Name
              %th Media
            - @contacts.sort_by {|c| [c.first_name, c.last_name] }.each do |contact|
              %tr
                %td
                  - link = "/contacts/#{contact.id}"
                  %a(title='contact details' href=link) #{contact.name}
                %td
                  - if contact.media && !contact.media.empty?
                    %p= contact.media.keys.collect(&:capitalize).join(", ")
                  - else
                    %p No media
        - else
          %p No contacts
      %div#push
    %div#footer
      = foot


{'fraction_non_alphanumeric': 0.1561572140304967, 'fraction_numerical': 0.004428564239343767, 'mean_word_length': 2.199484785058767, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '662426', 'n_tokens_mistral': 6013, 'n_tokens_neox': 5813, 'n_words': 1183}