Fix the default sorting for jobs

The UI would indicate a default sort by title when visiting the jobs
page.  This sort did not actually work, though, because sort was only
applied when an explicit order_by argument was given on the url.
Allow user to get task logs via UI
Clarify some error messages
Show some more information in job view
Merge pull request #224 from guidow/job_ui_more_info

Show some more information in job view
Merge pull request #223 from guidow/get_logfiles_ui

Allow user to get task logs via UI
Merge pull request #219 from guidow/fix_default_job_sort

Fix the default sorting for jobs
Change query for jobs list for more performance

The big group by clause at the end of query turned out to be a major
performance problem on postgresql.
This version gets the task counts for all jobs in four temporary tables
first, the left-outer-joins those tables.
Fix sorting by task counts
Track failures separately from attempts

This makes tasklogs of tasks that have been restarted a lot easier to
handle and is also a good first step towards treating user-initiated
interruptions of work differently from actual failures.
Change jobs tests to accomodate Task.failure col
Merge pull request #228 from guidow/optimize_jobs_list

Optimize jobs list
Change identity test to value test
Merge pull request #230 from guidow/failure_count

Track failures separately from attempts
Drastically reduce SQL queries fired in schedule

With SQlite and 500 jobs, this reduces the scheduler's runtime from
>20s to <1s on my machine.
Start oldest waiting job first, not youngest
Bugfix: Do not try to assign when job has no tasks

This bug would prevent the scheduler from running more than one job in
the same queue simultaneously.
Do not exceed jobtype's max_batch

Even if the batch setting for the current job is higher than that.