<commit_before>extends container
block container
    
  //- TODO define styles for transitional values
  style(type="text/css").
  
    text {
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      font-size: 24px;
      font-weight: bold;
    }
     
  //- TODO dynamically get the number of hosts
  //- TODO support multiple rainbow charts, one for each host
  //- TODO dynamically get the total number of cores, specific to host
  #rainbow
    
  //- http://bl.ocks.org/mbostock/5100636
  //- http://bl.ocks.org/mbostock/1346410
  script(type='text/javascript').
        
    var width = 960,
      height = 500,
      radius = Math.min(width, height) / 2,
      cores = 1;
  
    // control the start/end points for the arc
    // TBD what to do when > 1 ?
    var scale = d3.scale.linear()
      .domain([0, cores]) //max load value
      .range([- Math.PI/2, Math.PI/2]); //radians
      
    var arc = d3.svg.arc()
        .outerRadius(radius - 20);
    
    var svg = d3.select("#rainbow").append("svg")
        .attr("width", width)
        .attr("height", height)
      .append("g")
        .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

    var bg = svg.append("path")
      .attr("id", "max")
      .datum({startAngle: scale(0), endAngle: scale(cores), innerRadius:radius-100})
      .style("fill", "eee")
      .attr("d", arc);
        
    svg.append("path")
      .attr("id", "long")
      .datum({startAngle: scale(0), endAngle: scale(0), innerRadius: radius-80})
      .style("fill", "ddd")
      .attr("d", arc)
      .each(function(d) { console.log(d); this._current = d; });
      
    svg.append("path")
      .attr("id", "mid")
      .datum({startAngle: scale(0), endAngle: scale(0), innerRadius: radius-60})
      .style("fill", "ccc")
      .attr("d", arc)
      .each(function(d) { console.log(d); this._current = d; });
      
    svg.append("path")
      .attr("id", "short")
      .datum({startAngle: scale(0), endAngle: scale(0), innerRadius: radius-40})
      .style("fill", "bbb")
      .attr("d", arc)
      .each(function(d) { console.log(d); this._current = d; });
      
      

    var host = svg.append("text")
        .attr("text-anchor", "middle")
        .attr("dy", "-.5em")
        .text('hh');
        
    var curr = svg.append("text")
        .attr("text-anchor", "middle")
        .attr("dy", "-2em")
        .text('cc');

    function updateData() {
    
      d3.csv("/api/v1/summary/localhost.localdomain/kernel.all.load", function(json) {

        console.log(json);
        var data = {};
        
        data.host = 'localhost';
        data.short = +json[0].units;
        data.med = +json[1].units;
        data.long = +json[2].units;
        
        console.log(data);
        
        host.text(data.host);
        curr.text(data.short);
        
        var sp = svg.select("path#short")
          .datum({startAngle: scale(0), 
                  // don't overdraw arc when over 100%
                  endAngle: scale(Math.min(data.short/cores, 1.0)), 
                  innerRadius: radius-40,
                  load: data.short,
                  perc: data.short/cores});
        
        sp.transition()
          .duration(750)
          .attrTween("d", arcTween);
          
        sp.transition()
          .delay(750)
          .style('fill', function(d) {
            if (d.perc > 1.0)
            {
              return '#d00';
            }
            return '#ddd';
          });
            
            
            
            
            
        var mp = svg.select("path#mid")
          .datum({startAngle: scale(0), 
                  // don't overdraw arc when over 100%
                  endAngle: scale(Math.min(data.med/cores, 1.0)), 
                  innerRadius: radius-60,
                  load: data.med,
                  perc: data.med/cores});
        
        mp.transition()
          .duration(750)
          .attrTween("d", arcTween);
          
        mp.transition()
          .delay(750)
          .style('fill', function(d) {
            if (d.perc > 1.0)
            {
              return '#c00';
            }
            return '#ccc';
          });
           
        var lp = svg.select("path#long")
          .datum({startAngle: scale(0), 
                  // don't overdraw arc when over 100%
                  endAngle: scale(Math.min(data.long/cores, 1.0)), 
                  innerRadius: radius-80,
                  load: data.long,
                  perc: data.long/cores});
        
        lp.transition()
          .duration(750)
          .attrTween("d", arcTween);
          
        lp.transition()
          .delay(750)
          .style('fill', function(d) {
            if (d.perc > 1.0)
            {
              return '#b00';
            }
            return '#bbb';
          });
        
        
        if (data.short > cores &&
            data.med > cores && 
            data.long > cores)
        {
          bg.transition()
            .delay(750)
            .style('fill', '#e00');
        }
        else
        {
          bg.transition()
            .delay(750)
            .style('fill', '#eee');
        }
      });
    }


    // Store the displayed angles in _current.
    // Then, interpolate from _current to the new angles.
    // During the transition, _current is updated in-place by d3.interpolate.
    function arcTween(a) {
      var i = d3.interpolate(this._current, a);
      this._current = i(0);
      return function(t) {
        return arc(i(t));
      };
    }

    updateData();

    setInterval(updateData, 10000);
<commit_msg>fix colors<commit_after>extends container
block container
    
  //- TODO define styles for transitional values
  style(type="text/css").
  
    text {
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      font-size: 24px;
      font-weight: bold;
    }
     
  //- TODO dynamically get the number of hosts
  //- TODO support multiple rainbow charts, one for each host
  //- TODO dynamically get the total number of cores, specific to host
  #rainbow
    
  //- http://bl.ocks.org/mbostock/5100636
  //- http://bl.ocks.org/mbostock/1346410
  script(type='text/javascript').
        
    var width = 960,
      height = 500,
      radius = Math.min(width, height) / 2,
      cores = 1;
  
    // control the start/end points for the arc
    // TBD what to do when > 1 ?
    var scale = d3.scale.linear()
      .domain([0, cores]) //max load value
      .range([- Math.PI/2, Math.PI/2]); //radians
      
    var arc = d3.svg.arc()
        .outerRadius(radius - 20);
    
    var svg = d3.select("#rainbow").append("svg")
        .attr("width", width)
        .attr("height", height)
      .append("g")
        .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

    var bg = svg.append("path")
      .attr("id", "max")
      .datum({startAngle: scale(0), endAngle: scale(cores), innerRadius:radius-100})
      .style("fill", "eee")
      .attr("d", arc);
        
    svg.append("path")
      .attr("id", "long")
      .datum({startAngle: scale(0), endAngle: scale(0), innerRadius: radius-80})
      .style("fill", "ddd")
      .attr("d", arc)
      .each(function(d) { console.log(d); this._current = d; });
      
    svg.append("path")
      .attr("id", "mid")
      .datum({startAngle: scale(0), endAngle: scale(0), innerRadius: radius-60})
      .style("fill", "ccc")
      .attr("d", arc)
      .each(function(d) { console.log(d); this._current = d; });
      
    svg.append("path")
      .attr("id", "short")
      .datum({startAngle: scale(0), endAngle: scale(0), innerRadius: radius-40})
      .style("fill", "bbb")
      .attr("d", arc)
      .each(function(d) { console.log(d); this._current = d; });
      
      

    var host = svg.append("text")
        .attr("text-anchor", "middle")
        .attr("dy", "-.5em")
        .text('hh');
        
    var curr = svg.append("text")
        .attr("text-anchor", "middle")
        .attr("dy", "-2em")
        .text('cc');

    function updateData() {
    
      d3.csv("/api/v1/summary/localhost.localdomain/kernel.all.load", function(json) {

        console.log(json);
        var data = {};
        
        data.host = 'localhost';
        data.short = +json[0].units;
        data.med = +json[1].units;
        data.long = +json[2].units;
        
        console.log(data);
        
        host.text(data.host);
        curr.text(data.short);
        
        var sp = svg.select("path#short")
          .datum({startAngle: scale(0), 
                  // don't overdraw arc when over 100%
                  endAngle: scale(Math.min(data.short/cores, 1.0)), 
                  innerRadius: radius-40,
                  load: data.short,
                  perc: data.short/cores});
        
        sp.transition()
          .duration(750)
          .attrTween("d", arcTween);
          
        sp.transition()
          .delay(750)
          .style('fill', function(d) {
            if (d.perc > 1.0)
            {
              return '#b00';
            }
            return '#bbb';
          });
            
            
            
            
            
        var mp = svg.select("path#mid")
          .datum({startAngle: scale(0), 
                  // don't overdraw arc when over 100%
                  endAngle: scale(Math.min(data.med/cores, 1.0)), 
                  innerRadius: radius-60,
                  load: data.med,
                  perc: data.med/cores});
        
        mp.transition()
          .duration(750)
          .attrTween("d", arcTween);
          
        mp.transition()
          .delay(750)
          .style('fill', function(d) {
            if (d.perc > 1.0)
            {
              return '#c00';
            }
            return '#ccc';
          });
           
        var lp = svg.select("path#long")
          .datum({startAngle: scale(0), 
                  // don't overdraw arc when over 100%
                  endAngle: scale(Math.min(data.long/cores, 1.0)), 
                  innerRadius: radius-80,
                  load: data.long,
                  perc: data.long/cores});
        
        lp.transition()
          .duration(750)
          .attrTween("d", arcTween);
          
        lp.transition()
          .delay(750)
          .style('fill', function(d) {
            if (d.perc > 1.0)
            {
              return '#d00';
            }
            return '#ddd';
          });
        
        
        if (data.short > cores &&
            data.med > cores && 
            data.long > cores)
        {
          bg.transition()
            .delay(750)
            .style('fill', '#e00');
        }
        else
        {
          bg.transition()
            .delay(750)
            .style('fill', '#eee');
        }
      });
    }


    // Store the displayed angles in _current.
    // Then, interpolate from _current to the new angles.
    // During the transition, _current is updated in-place by d3.interpolate.
    function arcTween(a) {
      var i = d3.interpolate(this._current, a);
      this._current = i(0);
      return function(t) {
        return arc(i(t));
      };
    }

    updateData();

    setInterval(updateData, 10000);

{'fraction_non_alphanumeric': 0.15541559478399716, 'fraction_numerical': 0.022709128004967622, 'mean_word_length': 1.4508695652173913, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2045685', 'n_tokens_mistral': 3706, 'n_tokens_neox': 3449, 'n_words': 733}