Err... no :-)

Getting all results would be BAD!

See
https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets

*Slicing.* As explained in *Limiting
QuerySets*<https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets>,
a QuerySet can be sliced, using Python’s array-slicing syntax. Slicing an
unevaluated QuerySet usually returns another unevaluated QuerySet



On Tue, Feb 26, 2013 at 10:31 AM, Dariusz Fryta <notifications@github.com>wrote:

> In django_cron/__init__.py:
>
> >                  if not last_job.is_success and cron_job.schedule.retry_after_failure_mins:
> >                      if timezone.now() > last_job.start_time + timedelta(minutes=cron_job.schedule.retry_after_failure_mins):
> >                          return True
> >                      else:
> >                          return False
> >
> > -            qset = CronJobLog.objects.filter(code=cron_job.code, is_success=True, ran_at_time__isnull=True).order_by('-start_time')
> > -            if qset:
> > -                previously_ran_successful_cron = qset[0]
>
> Not really same. qset[0] gets ALL results (list) and then you show only
> first, latest() get only one result (LIMIT 1). This way its much much
> faster cos we dont have to get 200k items from db.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/Tivix/django-cron/pull/15/files#r3157981>
> .
>