code: def get_queued():
      
      return Email.objects.filter(status=STATUS.queued) \
          .select_related('template') \
          .filter(Q(scheduled_time__lte=now()) | Q(scheduled_time=None)) \
          .order_by(*get_sending_order()).prefetch_related('attachments')[:get_batch_size()]
docs: Returns a list of emails that should be sent:
       - Status is queued
       - Has scheduled_time lower than the current time or None