From 99b56b358483e8d9e7940be3f2ce60fabcc6981a Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 24 May 2023 12:17:14 +0300 Subject: [PATCH] downgraded csv writer ver --- Dockerfile | 2 +- bin/calc-users-stats | 3 +++ bin/users-calc | 3 --- src/Appwrite/Platform/Services/Tasks.php | 4 ++-- .../Platform/Tasks/{UsersCalc.php => CalcUsersStats.php} | 9 ++++----- 5 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 bin/calc-users-stats delete mode 100644 bin/users-calc rename src/Appwrite/Platform/Tasks/{UsersCalc.php => CalcUsersStats.php} (97%) diff --git a/Dockerfile b/Dockerfile index 9056e2a733..ec5cad2eab 100755 --- a/Dockerfile +++ b/Dockerfile @@ -119,7 +119,7 @@ RUN mkdir -p /storage/uploads && \ RUN chmod +x /usr/local/bin/doctor && \ chmod +x /usr/local/bin/patch-delete-schedule-updated-at-attribute && \ chmod +x /usr/local/bin/clear-card-cache && \ - chmod +x /usr/local/bin/users-calc && \ + chmod +x /usr/local/bin/calc-users-stats && \ chmod +x /usr/local/bin/maintenance && \ chmod +x /usr/local/bin/volume-sync && \ chmod +x /usr/local/bin/usage && \ diff --git a/bin/calc-users-stats b/bin/calc-users-stats new file mode 100644 index 0000000000..60472ed7a2 --- /dev/null +++ b/bin/calc-users-stats @@ -0,0 +1,3 @@ +#!/bin/sh + +php /usr/src/code/app/cli.php calc-users-stats $@ \ No newline at end of file diff --git a/bin/users-calc b/bin/users-calc deleted file mode 100644 index 3466d19e41..0000000000 --- a/bin/users-calc +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -php /usr/src/code/app/cli.php users-calc $@ \ No newline at end of file diff --git a/src/Appwrite/Platform/Services/Tasks.php b/src/Appwrite/Platform/Services/Tasks.php index e60f06044e..1073dfb0f7 100644 --- a/src/Appwrite/Platform/Services/Tasks.php +++ b/src/Appwrite/Platform/Services/Tasks.php @@ -19,7 +19,7 @@ use Appwrite\Platform\Tasks\Usage; use Appwrite\Platform\Tasks\Vars; use Appwrite\Platform\Tasks\Version; use Appwrite\Platform\Tasks\VolumeSync; -use Appwrite\Platform\Tasks\UsersCalc; +use Appwrite\Platform\Tasks\CalcUsersStats; class Tasks extends Service { @@ -43,6 +43,6 @@ class Tasks extends Service ->addAction(SDKs::getName(), new SDKs()) ->addAction(VolumeSync::getName(), new VolumeSync()) ->addAction(Specs::getName(), new Specs()) - ->addAction(UsersCalc::getName(), new UsersCalc()); + ->addAction(CalcUsersStats::getName(), new CalcUsersStats()); } } diff --git a/src/Appwrite/Platform/Tasks/UsersCalc.php b/src/Appwrite/Platform/Tasks/CalcUsersStats.php similarity index 97% rename from src/Appwrite/Platform/Tasks/UsersCalc.php rename to src/Appwrite/Platform/Tasks/CalcUsersStats.php index 2374043340..20d821bc88 100644 --- a/src/Appwrite/Platform/Tasks/UsersCalc.php +++ b/src/Appwrite/Platform/Tasks/CalcUsersStats.php @@ -3,7 +3,6 @@ namespace Appwrite\Platform\Tasks; use Exception; -use League\Csv\Reader; use Utopia\App; use Utopia\Platform\Action; use Utopia\Cache\Cache; @@ -15,7 +14,7 @@ use PHPMailer\PHPMailer\PHPMailer; use Utopia\Pools\Group; use Utopia\Registry\Registry; -class UsersCalc extends Action +class CalcUsersStats extends Action { private array $columns = [ 'Project ID', @@ -29,7 +28,7 @@ class UsersCalc extends Action public static function getName(): string { - return 'users-calc'; + return 'calc-users-stats'; } public function __construct() @@ -48,6 +47,7 @@ class UsersCalc extends Action public function action(Group $pools, Cache $cache, Database $dbForConsole, Registry $register): void { + //docker compose exec -t appwrite calc-users-stats Console::title('Cloud Users calculation V1'); Console::success(APP_NAME . ' cloud Users calculation has started'); @@ -141,7 +141,7 @@ class UsersCalc extends Action 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')); + $recipients = explode(',', App::getEnv('_APP_HAMSTER_RECIPIENTS', '')); foreach ($recipients as $recipient) { $mail->addAddress($recipient); @@ -153,7 +153,6 @@ class UsersCalc extends Action /** 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) {