{% extends "lava_scheduler_app/_content.html" %}

{% block content %}

<h2>Health Job Summary</h2>
<div style="display:inline-block; padding-left:20px;">

<h3>By Day</h3>
<div id="placeholder-daily" style="width:300px;height:200px;"></div>
<script type="text/javascript">
$(document).ready(function() {
var dpass = [];
var ddates= [];
{% for day in health_day_report %}
  dpass.push([{{forloop.counter0}}, 100*{{day.pass}}/({{day.pass}}+{{day.fail}})]);
  ddates.push([{{forloop.counter0}}, "<a href='{{day.failure_url}}'>{{day.date}}</a><br/>Pass: {{day.pass}}<br/>Fail: {{day.fail}}"]);
{% endfor %}

  var ddata = [
    {'label': '% Pass', 'data': dpass, 'color': '#00FF00'},
  ];

  $.plot($("#placeholder-daily"), ddata, {
    series: {
      lines: { show: true, fill: true, steps: false },
    },
    xaxis: {
      ticks: ddates,
    },
    yaxis: {
      max: 100,
    },
  });
}
);
</script>
</div>

<div style="display:inline-block; padding-left:40px;">

<h3>By Week</h3>
<div id="placeholder-weekly" style="width:500px;height:200px;"></div>
<script type="text/javascript">
$(document).ready(function() {
var wpass = [];
var wdates= [];
{% for week in health_week_report %}
  wpass.push([{{forloop.counter0}}, 100*{{week.pass}}/({{week.pass}}+{{week.fail}})]);
  wdates.push([{{forloop.counter0}}, "<a href='{{week.failure_url}}'>{{week.date}}</a><br/>Pass: {{week.pass}}<br/>Fail: {{week.fail}}"]);
{% endfor %}

  var wdata = [
    {'label': '% Pass', 'data': wpass, 'color': '#00FF00'},
  ];

  $.plot($("#placeholder-weekly"), wdata, {
    series: {
      lines: { show: true, fill: true, steps: false },
    },
    xaxis: {
      ticks: wdates,
    },
    yaxis: {
      max: 100,
    },
  });
}
);
</script>
</div>

<h2>Test Job Summary</h2>
<div style="display:inline-block; padding-left:20px;">

<h3>By Day</h3>
<div id="placeholder-job-daily" style="width:300px;height:200px;"></div>
<script type="text/javascript">
$(document).ready(function() {
var jdpass = [];
var jddates= [];
{% for day in job_day_report %}
  jdpass.push([{{forloop.counter0}}, 100*{{day.pass}}/({{day.pass}}+{{day.fail}})]);
  jddates.push([{{forloop.counter0}}, "<a href='{{day.failure_url}}'>{{day.date}}</a><br/>Pass: {{day.pass}}<br/>Fail: {{day.fail}}"]);
{% endfor %}

  var jddata = [
    {'label': '% Pass', 'data': jdpass, 'color': '#00FF00'},
  ];

  $.plot($("#placeholder-job-daily"), jddata, {
    series: {
      lines: { show: true, fill: true, steps: false },
    },
    xaxis: {
      ticks: jddates,
    },
    yaxis: {
      max: 100,
    },
  });
}
);
</script>
</div>

<div style="display:inline-block; padding-left:40px;">

<h3>By Week</h3>
<div id="placeholder-job-weekly" style="width:500px;height:200px;"></div>
<script type="text/javascript">
$(document).ready(function() {
var jwpass = [];
var jwdates= [];
{% for week in job_week_report %}
  jwpass.push([{{forloop.counter0}}, 100*{{week.pass}}/({{week.pass}}+{{week.fail}})]);
  jwdates.push([{{forloop.counter0}}, "<a href='{{week.failure_url}}'>{{week.date}}</a><br/>Pass: {{week.pass}}<br/>Fail: {{week.fail}}"]);
{% endfor %}

  var jwdata = [
    {'label': '% Pass', 'data': jwpass, 'color': '#00FF00'},
  ];

  $.plot($("#placeholder-job-weekly"), jwdata, {
    series: {
      lines: { show: true, fill: true, steps: false },
    },
    xaxis: {
      ticks: jwdates,
    },
    yaxis: {
      max: 100,
    },
  });
}
);
</script>
</div>

<h2>Longest Running Jobs</h2>
{% if long_running|length_is:"0" %}
There are no running jobs.
{% else %}
<ul>
{% for job in long_running %}
  <li><a href="{{job.get_absolute_url}}">{{job.id}}</a>: {{job.start_time}}</li>
{% endfor %}
</ul>
{% endif %}

{% endblock %}
