candlepin/candlepin — pull request #490 by cakofony (2014-01-13 21:55:32+00:00)
Title: Optimize uniqueByOwner job query, delete old failed jobs

This should probably be backported into 8.34 hotfix.

Replaced the detached query from getByClassAndOwner with a sort, hopefully there will be some speedup.
Remove old failed jobs (3-4 days+) to keep job status query time down.