{% for row in sql("select * from dss_job WHERE crawl_id = ? AND finished_at IS NULL", [dss_id], database=database) %}
<h2><a href='../dss_job/{{row['id']}}'>Job #{{row['id']}}</a> ({{row['status']}})</h2>
  Pending: {{ "{:,}".format(sql('select count(*) FROM dss_crawl_queue WHERE job_id = ?', [row['id']])[0][0]) }}
  Crawled: {{ "{:,}".format(sql('select count(*) FROM dss_crawl_queue_history WHERE job_id = ?', [row['id']])[0][0]) }}
  <form method='post' action='/{{ dss_db }}/-/scraper/crawl/{{ dss_id }}/cancel'>
    <input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
    <input type='hidden' name='id' value='{{ dss_id }}'/>
    <input type='submit' value='Cancel Job'>
  </form>
{% else %}
  <h2>No job currently running</h2>
  <form method='post' action='/{{ dss_db }}/-/scraper/crawl/{{ dss_id }}/start'>
    <input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
    <input type='hidden' name='id' value='{{ dss_id }}'/>
    <input type='submit' value='Start Job'>
  </form>
{% endfor %}


