Fix ActiveRecord error on completed tasks query