From 5163ce7cc9f9dccc9528222c467a98faefad817e Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 23 May 2023 19:46:45 +0300 Subject: [PATCH] calculating users per project task --- src/Appwrite/Platform/Tasks/UsersCalc.php | 68 +++++++++++------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/UsersCalc.php b/src/Appwrite/Platform/Tasks/UsersCalc.php index f59c158338..4689e20fdb 100644 --- a/src/Appwrite/Platform/Tasks/UsersCalc.php +++ b/src/Appwrite/Platform/Tasks/UsersCalc.php @@ -73,6 +73,7 @@ class UsersCalc extends Action $offset = 0; while (!empty($projects)) { foreach ($projects as $project) { + /** * Skip user projects with id 'console' */ @@ -121,43 +122,42 @@ class UsersCalc extends Action $offset = $offset + $limit; $count = $count + $sum; - - Console::log('Iterated through ' . ($count - 1) . '/' . $totalProjects . ' projects...'); - - /** @var PHPMailer $mail */ - $mail = $register->get('smtp'); - - $mail->clearAddresses(); - $mail->clearAllRecipients(); - $mail->clearReplyTos(); - $mail->clearAttachments(); - $mail->clearBCCs(); - $mail->clearCCs(); - - try { - /** Addresses */ - $mail->setFrom(App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), 'Appwrite Cloud Hamster'); - $recipients = explode(',', App::getEnv('_APP_HAMSTER_RECIPIENTS', 'shimon@appwrite.io')); - - foreach ($recipients as $recipient) { - $mail->addAddress($recipient); - } - - /** Attachments */ - $mail->addAttachment($this->path); - - /** Content */ - $mail->Subject = "Cloud Report for {$this->date}"; - $mail->Body = "Please find the daily cloud report atttached"; - - $mail->send(); - Console::success('Email has been sent!'); - } catch (Exception $e) { - Console::error("Message could not be sent. Mailer Error: {$mail->ErrorInfo}"); - } } + Console::log('Iterated through ' . $count - 1 . '/' . $totalProjects . ' projects...'); $pools ->get('console') ->reclaim(); + + /** @var PHPMailer $mail */ + $mail = $register->get('smtp'); + + $mail->clearAddresses(); + $mail->clearAllRecipients(); + $mail->clearReplyTos(); + $mail->clearAttachments(); + $mail->clearBCCs(); + $mail->clearCCs(); + + try { + /** Addresses */ + $mail->setFrom(App::getEnv('_APP_SYSTEM_EMAIL_ADDRESS', APP_EMAIL_TEAM), 'Appwrite Cloud Hamster'); + $recipients = explode(',', App::getEnv('_APP_HAMSTER_RECIPIENTS', 'shimon@appwrite.io')); + + foreach ($recipients as $recipient) { + $mail->addAddress($recipient); + } + + /** Attachments */ + $mail->addAttachment($this->path); + + /** Content */ + $mail->Subject = "Cloud Report for {$this->date}"; + $mail->Body = "Please find the daily cloud report atttached"; + + $mail->send(); + Console::success('Email has been sent!'); + } catch (Exception $e) { + Console::error("Message could not be sent. Mailer Error: {$mail->ErrorInfo}"); + } } }