<commit_before>extends layout

block append scripts
  script(type='text/javascript')
    $(document).ready(function(){
      var update_table = function(selected){
        var klass = "";
        var iter;
        if (selected == 'all'){
          klass = '.#{health.healthy},.#{health.unhealthy}';
        }else{
          klass = '.' + selected;
        }
        $('.data-row').each(function(index, item){
          item = $(item);
          if(item.is(klass)){
            item.show();
          }else{
            item.hide();
          }
        })
      };
      $('select#filter-health').change(function(e){
        var selected = e.target;
        var option = selected.options[selected.selectedIndex];
        var to_filter = $(option).attr('class');
        update_table(to_filter);
      });
      $('select#filter-health').val('#{health.unhealthy}');
      update_table('#{health.unhealthy}');
    });

block append css
  link(href='/static/css/devhealth.less', rel='stylesheet/less', type='text/css')
  link(href='/static/css/service_health.less', rel='stylesheet/less', type='text/css')
  style(type="text/css")
    .#{health.healthy}{
      background-color: green;
      font-size: 200%;
    }
    .#{health.unhealthy}{
      background-color: red;
      font-size: 200%;
    }
    table.table .table-hack{
      margin: 0; padding: 0; line-height: 0; height: 0; border: 0 none;
    }

   
block content
  -var hosts = service_health.get_data();
  .container
    if hosts
      h3(style='text-align:right')
        |Filter:
        select(id='filter-health')
          option(class='all')='All'
          option(class='#{health.healthy}')='Healthy'
          option(class='#{health.unhealthy}')='Unhealthy'
     section(id='services')     
      div.page-header
        h1 Services
      table.table.table-bordered.table-sort#service-stats
        thead
          tr#header
            th Health
            th Name
            th Host
            th Type
            th IP Address
            th Last Updated
        tbody
          for host in hosts
            for service, name in host.services
              - var service_color = service.healthy ? health.healthy : health.unhealthy
              - var service_error_msg = service.error_msg
              - var service_metrics = service.metrics
              - var service_id = host.service_name.replace(/\./g,'\_')
                tr(data-toggle='collapse', data-target='#'+service_id+service.service)
                  td(class=service_color, style='text-align: center;')=(service.healthy ? '☺' : '☹')
                  td
                    button.btn.btn-info
                      =host.service_name
                  td
                    a(href='#host-name-'+host.service_name)=host.service_name
                  td
                    =service.service
                  td=host.ip
                  td=humane_time(host.time)
                tr
                 td(colspan=6)
                    if service_metrics || service_error_msg
                      div(id=service_id+service.service, class='collapse')
                        table.table
                          thead
                            tr
                              th Name
                              th Value
                          tbody
                            if service_error_msg
                              tr
                                td.alert-danger(colspan=2)=service_error_msg
                            if service_metrics
                              for metric in service_metrics
                                tr
                                  td=metric.name
                                  td=metric.value
          tr(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
    section(id='hosts')
      div.page-header
        h1 Hosts
      table.table.table-bordered#host-stats
        thead
          tr#header
            th Health
            th Hostname
            th(colspan=2) Services Provided
            th IP Address
            th Last Updated
        tbody
          for host in hosts
            - var host_name = host.service_name;
            - var host_color = host.healthy ? health.healthy : health.unhealthy
            tr
              td(class=host_color+' data-row host-row', style='text-align: center;')=(host.healthy ? '☺' : '☹')
              td
                a(name="host-name-"+host_name)=host_name
              td(colspan=2)
                -var services = Object.keys(host.services);
                | [
                for key in services
                  a(href='#'+host_name+'_'+key)=key
                  | ,&nbsp;
                | ]
              td=host.ip
              td=humane_time(host.time)<commit_msg>Service Health: Color separted from Health, filter broken.<commit_after>extends layout

block append scripts
  script(type='text/javascript')
    $(document).ready(function(){
      var update_table = function(selected){
        var klass = "";
        var iter;
        if (selected == 'all'){
          klass = '.#{health.healthy},.#{health.unhealthy}';
        }else{
          klass = '.' + selected;
        }
        $('.data-row').each(function(index, item){
          item = $(item);
          if(item.is(klass)){
            item.show();
          }else{
            item.hide();
          }
        })
      };
      $('select#filter-health').change(function(e){
        var selected = e.target;
        var option = selected.options[selected.selectedIndex];
        var to_filter = $(option).attr('class');
        update_table(to_filter);
      });
      $('select#filter-health').val('#{health.unhealthy}');
      update_table('#{health.unhealthy}');
    });

block append css
  link(href='/static/css/devhealth.less', rel='stylesheet/less', type='text/css')
  link(href='/static/css/service_health.less', rel='stylesheet/less', type='text/css')
  style(type="text/css")
    .health-healthycolor {
      background-color: green;
      font-size: 300%;
      text-align: center;
    }
    .health-unhealthycolor {
      background-color: red;
      font-size: 300%;
      text-align: center;
    }
    table.table .table-hack{
      margin: 0; padding: 0; line-height: 0; height: 0; border: 0 none; empty-cells: hide;
    }

   
block content
  -var hosts = service_health.get_data();
  .container
    if hosts
      h3(style='text-align:right')
        |Filter:
        select(id='filter-health')
          option(class='all')='All'
          option(class='#{health.healthy}')='Healthy'
          option(class='#{health.unhealthy}')='Unhealthy'
     section(id='services')     
      div.page-header
        h1 Services
      table.table.table-bordered.table-sort#service-stats
        thead
          tr#header
            th Health
            th Name
            th Host
            th Type
            th IP Address
            th Last Updated
        tbody
          for host in hosts
            for service, name in host.services
              - var service_health = service.healthy ? health.healthy : health.unhealthy
              - var service_error_msg = service.error_msg
              - var service_metrics = service.metrics
              - var service_id = host.service_name.replace(/\./g,'\_')
                tr(class=service_health, data-toggle='collapse', data-target='#'+service_id+service.service)
                  td(class=service_health+'color')=(service.health ? '☺' : '☹')
                  td
                    button.btn.btn-info
                      =host.service_name
                  td
                    a(href='#host-name-'+host.service_name)=host.service_name
                  td
                    =service.service
                  td=host.ip
                  td=humane_time(host.time)
                tr
                 td(colspan=6)
                    if service_metrics || service_error_msg
                      div(id=service_id+service.service, class='collapse')
                        table.table
                          thead
                            tr
                              th Name
                              th Value
                          tbody
                            if service_error_msg
                              tr
                                td.alert-danger(colspan=2)=service_error_msg
                            if service_metrics
                              for metric in service_metrics
                                tr
                                  td=metric.name
                                  td=metric.value
          tr(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
            td(class="table-hack")
    section(id='hosts')
      div.page-header
        h1 Hosts
      table.table.table-bordered#host-stats
        thead
          tr#header
            th Health
            th Hostname
            th(colspan=2) Services Provided
            th IP Address
            th Last Updated
        tbody
          for host in hosts
            - var host_name = host.service_name;
            - var host_health = host.healthy ? health.healthy : health.unhealthy
            tr
              td(class=host_health+'color host-row', style='text-align: center;')=(host.healthy ? '☺' : '☹')
              td
                a(name="host-name-"+host_name)=host_name
              td(colspan=2)
                -var services = Object.keys(host.services);
                | [
                for key in services
                  a(href='#'+host_name+'_'+key)=key
                  | ,&nbsp;
                | ]
              td=host.ip
              td=humane_time(host.time)
{'fraction_non_alphanumeric': 0.11594057418189119, 'fraction_numerical': 0.0036137321822927123, 'mean_word_length': 1.3687589158345221, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1987683', 'n_tokens_mistral': 2747, 'n_tokens_neox': 2640, 'n_words': 492}