from celery.task import task

from . import models
from . import send_backends


@task
def send_daily_email_blasts(blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    send_backends.sync_daily_email_blasts(blast)


@task
def send_recipients_list(recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    send_backends.sync_recipients_list(recipients_list, blast)


@task
def send_recipients(recipient_pk, recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    recipient = models.Recipient.objects.get(pk=recipient_pk)
    send_backends.sync_recipient(recipient, recipients_list, blast)

from celery.task import task

from . import models
from .send_backends import sync


@task
def send_daily_email_blasts(blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    sync.sync_daily_email_blasts(blast)


@task
def send_recipients_list(recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    sync.sync_recipients_list(recipients_list, blast)


@task
def send_recipients(recipient_pk, recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    recipient = models.Recipient.objects.get(pk=recipient_pk)
    sync.sync_recipient(recipient, recipients_list, blast)

Fix every single async task was broken
Fix every single async task was broken

  from celery.task import task
  
  from . import models
- from . import send_backends
+ from .send_backends import sync
  
  
  @task
  def send_daily_email_blasts(blast_pk):
      blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
-     send_backends.sync_daily_email_blasts(blast)
+     sync.sync_daily_email_blasts(blast)
  
  
  @task
  def send_recipients_list(recipients_list_pk, blast_pk):
      blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
      recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
-     send_backends.sync_recipients_list(recipients_list, blast)
+     sync.sync_recipients_list(recipients_list, blast)
  
  
  @task
  def send_recipients(recipient_pk, recipients_list_pk, blast_pk):
      blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
      recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
      recipient = models.Recipient.objects.get(pk=recipient_pk)
-     send_backends.sync_recipient(recipient, recipients_list, blast)
+     sync.sync_recipient(recipient, recipients_list, blast)
  
Fix every single async task was broken
## Code Before:
from celery.task import task

from . import models
from . import send_backends


@task
def send_daily_email_blasts(blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    send_backends.sync_daily_email_blasts(blast)


@task
def send_recipients_list(recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    send_backends.sync_recipients_list(recipients_list, blast)


@task
def send_recipients(recipient_pk, recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    recipient = models.Recipient.objects.get(pk=recipient_pk)
    send_backends.sync_recipient(recipient, recipients_list, blast)

## Instruction:
Fix every single async task was broken
## Code After:
from celery.task import task

from . import models
from .send_backends import sync


@task
def send_daily_email_blasts(blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    sync.sync_daily_email_blasts(blast)


@task
def send_recipients_list(recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    sync.sync_recipients_list(recipients_list, blast)


@task
def send_recipients(recipient_pk, recipients_list_pk, blast_pk):
    blast = models.DailyEmailBlast.objects.get(pk=blast_pk)
    recipients_list = models.RecipientList.objects.get(pk=recipients_list_pk)
    recipient = models.Recipient.objects.get(pk=recipient_pk)
    sync.sync_recipient(recipient, recipients_list, blast)
