From 40e17ad6255992b813ddc38194950f8fa373b7ce Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 17 Jan 2024 21:53:12 +0200 Subject: [PATCH 01/15] hamster additions --- src/Appwrite/Platform/Workers/Hamster.php | 37 +++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 3bb443faea..aded2a664c 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -277,7 +277,7 @@ class Hamster extends Action $limit = $periodValue['limit']; $period = $periodValue['period']; - $requestDocs = $dbForProject->find('stats_v2', [ + $requestDocs = $dbForProject->find('stats', [ Query::equal('period', [$period]), Query::equal('metric', [$metric]), Query::limit($limit), @@ -302,8 +302,8 @@ class Hamster extends Action /** * Workaround to combine network.inbound+network.outbound as network. */ - $statsPerProject["usage_bandwidth_infinity"] = $statsPerProject["usage_inbound_infinity"] + $statsPerProject["usage_outbound_infinity"]; - $statsPerProject["usage_bandwidth_24h"] = $statsPerProject["usage_inbound_24h"] + $statsPerProject["usage_outbound_24h"]; + $statsPerProject["usage_network_infinity"] = $statsPerProject["usage_inbound_infinity"] + $statsPerProject["usage_outbound_infinity"]; + $statsPerProject["usage_network_24h"] = $statsPerProject["usage_inbound_24h"] + $statsPerProject["usage_outbound_24h"]; unset($statsPerProject["usage_outbound_24h"]); unset($statsPerProject["usage_inbound_24h"]); unset($statsPerProject["usage_outbound_infinity"]); @@ -368,6 +368,19 @@ class Hamster extends Action throw new \Exception('Membership not found. Skipping organization : ' . $organization->getId()); } + $billingPlan = $membership->getAttribute('billingPlan', null); + $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); + + if (!empty($billingPlan) && empty($billingPlanDowngrade)) { + $statsPerOrganization['billing-plan'] = $billingPlan; + } + + if (in_array($billingPlan, ['tier-1', 'tier-2'])) { + $billingStartDate = $membership->getAttribute('billingStartDate', null); + $statsPerOrganization['billing-start-plan-date'] = $billingStartDate; + } + + $userId = $membership->getAttribute('userId', null); if ($userId) { $user = $dbForConsole->getDocument('users', $userId); @@ -410,6 +423,24 @@ class Hamster extends Action try { $statsPerUser = []; + $membership = $dbForConsole->findOne('teams', [ + Query::equal('userInternalId', [$user->getInternalId()]) + ]); + + if (!empty($membership) || !$membership->isEmpty()) { + $billingPlan = $membership->getAttribute('billingPlan', null); + $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); + + if (!empty($billingPlan) && empty($billingPlanDowngrade)) { + $statsPerUser['billing-plan'] = $billingPlan; + } + + if (in_array($billingPlan, ['tier-1', 'tier-2'])) { + $billingStartDate = $membership->getAttribute('billingStartDate', null); + $statsPerUser['billing-start-plan-date'] = $billingStartDate; + } + } + $statsPerUser['time'] = $user->getAttribute('$time'); /** Organization name */ From f9d6da6672186d065ec1093eb10983d5f5b6d3ed Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 17 Jan 2024 21:58:16 +0200 Subject: [PATCH 02/15] hamster additions --- src/Appwrite/Platform/Workers/Hamster.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index aded2a664c..6acbc386b0 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -300,10 +300,10 @@ class Hamster extends Action }); /** - * Workaround to combine network.inbound+network.outbound as network. + * Workaround to combine network.Inbound+network.outbound as bandwidth. */ - $statsPerProject["usage_network_infinity"] = $statsPerProject["usage_inbound_infinity"] + $statsPerProject["usage_outbound_infinity"]; - $statsPerProject["usage_network_24h"] = $statsPerProject["usage_inbound_24h"] + $statsPerProject["usage_outbound_24h"]; + $statsPerProject["usage_bandwidth_infinity"] = $statsPerProject["usage_inbound_infinity"] + $statsPerProject["usage_outbound_infinity"]; + $statsPerProject["usage_bandwidth_24h"] = $statsPerProject["usage_inbound_24h"] + $statsPerProject["usage_outbound_24h"]; unset($statsPerProject["usage_outbound_24h"]); unset($statsPerProject["usage_inbound_24h"]); unset($statsPerProject["usage_outbound_infinity"]); From a954cea8fca19b809ce5db0634d210aff2bec739 Mon Sep 17 00:00:00 2001 From: Shimon Newman Date: Wed, 17 Jan 2024 22:08:29 +0200 Subject: [PATCH 03/15] Update src/Appwrite/Platform/Workers/Hamster.php Co-authored-by: Christy Jacob --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 6acbc386b0..b366f99191 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -437,7 +437,7 @@ class Hamster extends Action if (in_array($billingPlan, ['tier-1', 'tier-2'])) { $billingStartDate = $membership->getAttribute('billingStartDate', null); - $statsPerUser['billing-start-plan-date'] = $billingStartDate; + $statsPerUser['billing_start_date'] = $billingStartDate; } } From 5d164e0592da64ff608ce2465de01d865a147345 Mon Sep 17 00:00:00 2001 From: Shimon Newman Date: Wed, 17 Jan 2024 22:08:37 +0200 Subject: [PATCH 04/15] Update src/Appwrite/Platform/Workers/Hamster.php Co-authored-by: Christy Jacob --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index b366f99191..472b70b130 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -432,7 +432,7 @@ class Hamster extends Action $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); if (!empty($billingPlan) && empty($billingPlanDowngrade)) { - $statsPerUser['billing-plan'] = $billingPlan; + $statsPerUser['billing_plan'] = $billingPlan; } if (in_array($billingPlan, ['tier-1', 'tier-2'])) { From c1ca623babbd8001788cd0d708bce99357e82421 Mon Sep 17 00:00:00 2001 From: Shimon Newman Date: Wed, 17 Jan 2024 22:08:44 +0200 Subject: [PATCH 05/15] Update src/Appwrite/Platform/Workers/Hamster.php Co-authored-by: Christy Jacob --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 472b70b130..537f94e23e 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -377,7 +377,7 @@ class Hamster extends Action if (in_array($billingPlan, ['tier-1', 'tier-2'])) { $billingStartDate = $membership->getAttribute('billingStartDate', null); - $statsPerOrganization['billing-start-plan-date'] = $billingStartDate; + $statsPerOrganization['billing_start_date'] = $billingStartDate; } From 3f63b87ea62900f4d656c210fbaa1797ad8852ac Mon Sep 17 00:00:00 2001 From: Shimon Newman Date: Wed, 17 Jan 2024 22:09:02 +0200 Subject: [PATCH 06/15] Update src/Appwrite/Platform/Workers/Hamster.php Co-authored-by: Christy Jacob --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 537f94e23e..bfaed2ef06 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -372,7 +372,7 @@ class Hamster extends Action $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); if (!empty($billingPlan) && empty($billingPlanDowngrade)) { - $statsPerOrganization['billing-plan'] = $billingPlan; + $statsPerOrganization['billing_plan'] = $billingPlan; } if (in_array($billingPlan, ['tier-1', 'tier-2'])) { From e5245909e3ed6071e45024c5a6b9f9df71619e7e Mon Sep 17 00:00:00 2001 From: Shimon Newman Date: Wed, 17 Jan 2024 22:09:17 +0200 Subject: [PATCH 07/15] Update src/Appwrite/Platform/Workers/Hamster.php Co-authored-by: Christy Jacob --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index bfaed2ef06..255f3a3eb0 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -371,7 +371,7 @@ class Hamster extends Action $billingPlan = $membership->getAttribute('billingPlan', null); $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); - if (!empty($billingPlan) && empty($billingPlanDowngrade)) { + if (!empty($billingPlan) && is_null($billingPlanDowngrade)) { $statsPerOrganization['billing_plan'] = $billingPlan; } From 0d106684ae5dd3e91d19cb7e7844953059c831bc Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 17 Jan 2024 22:10:06 +0200 Subject: [PATCH 08/15] hamster additions --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 255f3a3eb0..c0c1ad8936 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -277,7 +277,7 @@ class Hamster extends Action $limit = $periodValue['limit']; $period = $periodValue['period']; - $requestDocs = $dbForProject->find('stats', [ + $requestDocs = $dbForProject->find('stats_v2', [ Query::equal('period', [$period]), Query::equal('metric', [$metric]), Query::limit($limit), From 6bd810cb3aa7ffd1a1b40b0529a08ae6f7adf531 Mon Sep 17 00:00:00 2001 From: shimon Date: Wed, 17 Jan 2024 22:19:00 +0200 Subject: [PATCH 09/15] hamster additions --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index c0c1ad8936..81970aa7d0 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -431,7 +431,7 @@ class Hamster extends Action $billingPlan = $membership->getAttribute('billingPlan', null); $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); - if (!empty($billingPlan) && empty($billingPlanDowngrade)) { + if (!empty($billingPlan) && is_null($billingPlanDowngrade)) { $statsPerUser['billing_plan'] = $billingPlan; } From c116de29e15f19bd21ee0fdfd4e8193c30e827ae Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 22 Jan 2024 09:28:45 +0200 Subject: [PATCH 10/15] Added marked_for_deletion and billing_plan_downgrade to hamster export --- src/Appwrite/Platform/Workers/Hamster.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 81970aa7d0..0da625c543 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -344,7 +344,6 @@ class Hamster extends Action /** * @param Document $organization * @param Database $dbForConsole - * @throws \Utopia\Database\Exception */ private function getStatsForOrganization(Document $organization, Database $dbForConsole): void { @@ -380,6 +379,8 @@ class Hamster extends Action $statsPerOrganization['billing_start_date'] = $billingStartDate; } + $statsPerOrganization['marked_for_deletion'] = $membership->getAttribute('markedForDeletion', 0); + $statsPerOrganization['billing_plan_downgrade'] = $billingPlanDowngrade; $userId = $membership->getAttribute('userId', null); if ($userId) { From 0e30f6533e574abf4f64e62fdd869511610f2e61 Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 22 Jan 2024 09:54:09 +0200 Subject: [PATCH 11/15] Added marked_for_deletion and billing_plan_downgrade to hamster export --- src/Appwrite/Platform/Workers/Hamster.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 0da625c543..dcc4404dda 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -367,19 +367,19 @@ class Hamster extends Action throw new \Exception('Membership not found. Skipping organization : ' . $organization->getId()); } - $billingPlan = $membership->getAttribute('billingPlan', null); - $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); + $billingPlan = $organization->getAttribute('billingPlan', null); + $billingPlanDowngrade = $organization->getAttribute('billingPlanDowngrade', null); if (!empty($billingPlan) && is_null($billingPlanDowngrade)) { $statsPerOrganization['billing_plan'] = $billingPlan; } if (in_array($billingPlan, ['tier-1', 'tier-2'])) { - $billingStartDate = $membership->getAttribute('billingStartDate', null); + $billingStartDate = $organization->getAttribute('billingStartDate', null); $statsPerOrganization['billing_start_date'] = $billingStartDate; } - $statsPerOrganization['marked_for_deletion'] = $membership->getAttribute('markedForDeletion', 0); + $statsPerOrganization['marked_for_deletion'] = $organization->getAttribute('markedForDeletion', 0); $statsPerOrganization['billing_plan_downgrade'] = $billingPlanDowngrade; $userId = $membership->getAttribute('userId', null); @@ -424,20 +424,20 @@ class Hamster extends Action try { $statsPerUser = []; - $membership = $dbForConsole->findOne('teams', [ + $organization = $dbForConsole->findOne('teams', [ Query::equal('userInternalId', [$user->getInternalId()]) ]); - if (!empty($membership) || !$membership->isEmpty()) { - $billingPlan = $membership->getAttribute('billingPlan', null); - $billingPlanDowngrade = $membership->getAttribute('billingPlanDowngrade', null); + if (!empty($organization) || !$organization->isEmpty()) { + $billingPlan = $organization->getAttribute('billingPlan', null); + $billingPlanDowngrade = $organization->getAttribute('billingPlanDowngrade', null); if (!empty($billingPlan) && is_null($billingPlanDowngrade)) { $statsPerUser['billing_plan'] = $billingPlan; } if (in_array($billingPlan, ['tier-1', 'tier-2'])) { - $billingStartDate = $membership->getAttribute('billingStartDate', null); + $billingStartDate = $organization->getAttribute('billingStartDate', null); $statsPerUser['billing_start_date'] = $billingStartDate; } } From 9fc1b0b71b01bc56ec43a51e99703ef0de81499d Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 22 Jan 2024 10:09:13 +0200 Subject: [PATCH 12/15] Added marked_for_deletion and billing_plan_downgrade to hamster export --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index dcc4404dda..1830f4b9b1 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -428,7 +428,7 @@ class Hamster extends Action Query::equal('userInternalId', [$user->getInternalId()]) ]); - if (!empty($organization) || !$organization->isEmpty()) { + if (!empty($organization) && !$organization->isEmpty()) { $billingPlan = $organization->getAttribute('billingPlan', null); $billingPlanDowngrade = $organization->getAttribute('billingPlanDowngrade', null); From ff7523d6db6e2dbe72f783be8eb527760e83f1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=B7=E5=8D=8E=20=E5=88=98?= Date: Mon, 22 Jan 2024 08:26:38 +0000 Subject: [PATCH 13/15] chore: refactor code --- src/Appwrite/Platform/Workers/Hamster.php | 75 ++++++++++++++--------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index 1830f4b9b1..e96748beef 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -218,6 +218,16 @@ class Hamster extends Action } } + /** Add billing information to the project */ + $organization = $dbForConsole->findOne('teams', [ + Query::equal('$internalId', [$teamInternalId]) + ]); + + /** Add billing information */ + $billing = $this->getBillingDetails($organization); + $statsPerProject['billing_plan'] = $billing['billing_plan'] ?? null; + $statsPerProject['billing_start_date'] = $billing['billing_start_date'] ?? null; + /** Get Domains */ $statsPerProject['custom_domains'] = $dbForConsole->count('rules', [ Query::equal('projectInternalId', [$project->getInternalId()]), @@ -362,32 +372,22 @@ class Hamster extends Action $membership = $dbForConsole->findOne('memberships', [ Query::equal('teamInternalId', [$organization->getInternalId()]), ]); - if (!$membership || $membership->isEmpty()) { throw new \Exception('Membership not found. Skipping organization : ' . $organization->getId()); } - - $billingPlan = $organization->getAttribute('billingPlan', null); - $billingPlanDowngrade = $organization->getAttribute('billingPlanDowngrade', null); - - if (!empty($billingPlan) && is_null($billingPlanDowngrade)) { - $statsPerOrganization['billing_plan'] = $billingPlan; - } - - if (in_array($billingPlan, ['tier-1', 'tier-2'])) { - $billingStartDate = $organization->getAttribute('billingStartDate', null); - $statsPerOrganization['billing_start_date'] = $billingStartDate; - } - - $statsPerOrganization['marked_for_deletion'] = $organization->getAttribute('markedForDeletion', 0); - $statsPerOrganization['billing_plan_downgrade'] = $billingPlanDowngrade; - $userId = $membership->getAttribute('userId', null); if ($userId) { $user = $dbForConsole->getDocument('users', $userId); $statsPerOrganization['email'] = $user->getAttribute('email', null); } + /** Add billing information */ + $billing = $this->getBillingDetails($organization); + $statsPerOrganization['billing_plan'] = $billing['billing_plan'] ?? null; + $statsPerOrganization['billing_start_date'] = $billing['billing_start_date'] ?? null; + $statsPerOrganization['marked_for_deletion'] = $billing['markedForDeletion'] ?? 0; + $statsPerOrganization['billing_plan_downgrade'] = $billing['billing_plan_downgrade'] ?? null; + /** Organization Creation Date */ $statsPerOrganization['created'] = $organization->getAttribute('$createdAt'); @@ -428,19 +428,10 @@ class Hamster extends Action Query::equal('userInternalId', [$user->getInternalId()]) ]); - if (!empty($organization) && !$organization->isEmpty()) { - $billingPlan = $organization->getAttribute('billingPlan', null); - $billingPlanDowngrade = $organization->getAttribute('billingPlanDowngrade', null); - - if (!empty($billingPlan) && is_null($billingPlanDowngrade)) { - $statsPerUser['billing_plan'] = $billingPlan; - } - - if (in_array($billingPlan, ['tier-1', 'tier-2'])) { - $billingStartDate = $organization->getAttribute('billingStartDate', null); - $statsPerUser['billing_start_date'] = $billingStartDate; - } - } + /** Add billing information */ + $billing = $this->getBillingDetails($organization); + $statsPerUser['billing_plan'] = $billing['billing_plan'] ?? null; + $statsPerUser['billing_start_date'] = $billing['billing_start_date'] ?? null; $statsPerUser['time'] = $user->getAttribute('$time'); @@ -478,4 +469,28 @@ class Hamster extends Action Console::error($e->getMessage()); } } + + private function getBillingDetails(Document $team): array + { + $billing = []; + + if (!empty($team) && !$team->isEmpty()) { + $billingPlan = $team->getAttribute('billingPlan', null); + $billingPlanDowngrade = $team->getAttribute('billingPlanDowngrade', null); + + if (!empty($billingPlan) && empty($billingPlanDowngrade)) { + $billing['billing_plan'] = $billingPlan; + } + + if (in_array($billingPlan, ['tier-1', 'tier-2'])) { + $billingStartDate = $team->getAttribute('billingStartDate', null); + $billing['billing_start_date'] = $billingStartDate; + } + + $billing['marked_for_deletion'] = $team->getAttribute('markedForDeletion', 0); + $billing['billing_plan_downgrade'] = $billingPlanDowngrade; + } + + return $billing; + } } From d04f9f41c3fb3e665b3a5d279428105739e515c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=B7=E5=8D=8E=20=E5=88=98?= Date: Mon, 22 Jan 2024 08:30:48 +0000 Subject: [PATCH 14/15] chore: refactor code --- src/Appwrite/Platform/Workers/Hamster.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index e96748beef..ab2b6e6031 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -223,7 +223,6 @@ class Hamster extends Action Query::equal('$internalId', [$teamInternalId]) ]); - /** Add billing information */ $billing = $this->getBillingDetails($organization); $statsPerProject['billing_plan'] = $billing['billing_plan'] ?? null; $statsPerProject['billing_start_date'] = $billing['billing_start_date'] ?? null; @@ -367,7 +366,6 @@ class Hamster extends Action /** Organization name */ $statsPerOrganization['name'] = $organization->getAttribute('name'); - /** Get Email and of the organization owner */ $membership = $dbForConsole->findOne('memberships', [ Query::equal('teamInternalId', [$organization->getInternalId()]), @@ -424,17 +422,17 @@ class Hamster extends Action try { $statsPerUser = []; + $statsPerUser['time'] = $user->getAttribute('$time'); + + /** Add billing information */ $organization = $dbForConsole->findOne('teams', [ Query::equal('userInternalId', [$user->getInternalId()]) ]); - /** Add billing information */ $billing = $this->getBillingDetails($organization); $statsPerUser['billing_plan'] = $billing['billing_plan'] ?? null; $statsPerUser['billing_start_date'] = $billing['billing_start_date'] ?? null; - $statsPerUser['time'] = $user->getAttribute('$time'); - /** Organization name */ $statsPerUser['name'] = $user->getAttribute('name'); From 2b865bdf97849e5f7d7eaaae6f114db8d40f884e Mon Sep 17 00:00:00 2001 From: shimon Date: Mon, 22 Jan 2024 11:29:11 +0200 Subject: [PATCH 15/15] Added marked_for_deletion and billing_plan_downgrade to hamster export --- src/Appwrite/Platform/Workers/Hamster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Hamster.php b/src/Appwrite/Platform/Workers/Hamster.php index ab2b6e6031..c12754d134 100644 --- a/src/Appwrite/Platform/Workers/Hamster.php +++ b/src/Appwrite/Platform/Workers/Hamster.php @@ -468,7 +468,7 @@ class Hamster extends Action } } - private function getBillingDetails(Document $team): array + private function getBillingDetails(Document $team): array { $billing = [];