Skip to content

Commit

Permalink
Cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianWilhelm committed Dec 22, 2023
1 parent e0f93f3 commit 1491f1c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/pytanis/helpdesk/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Mail(BaseModel):
class MailClient:
"""Mail client for mass mails over HelpDesk"""

n_batch: int = 20 # n messages are a batch
batch_size: int = 20 # n messages are a batch
wait_time: int = 30 # wait time after eacht batch before next

def __init__(self, helpdesk_client: HelpDeskClient | None = None):
Expand Down Expand Up @@ -120,7 +120,7 @@ def send(
"""Send a mail to all recipients using HelpDesk"""
errors = []
tickets = []
for idx, recipient in enumerate(tqdm(mail.recipients)):
for idx, recipient in enumerate(tqdm(mail.recipients), start=1):
recip_mail = mail.model_copy()
try:
recip_mail.subject = mail.subject.format(recipient=recipient, mail=mail)
Expand All @@ -137,7 +137,7 @@ def send(
errors.append((recipient, e))
else:
tickets.append((recipient, resp_ticket))
if (idx + 1) % self.n_batch == 0:
if idx % self.batch_size == 0:
time.sleep(self.wait_time)

return tickets, errors

0 comments on commit 1491f1c

Please sign in to comment.