From c5dfc42a606fa09bbd99fca0cb364e14c030a7e6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 6 May 2026 18:12:17 +1200 Subject: [PATCH] refactor(insights): rename ctas collection to insightCTAs Disambiguate the platform-level collection name. Field/request-param remains `ctas` (the embedded array on the insight response). Co-Authored-By: Claude Opus 4.7 (1M context) --- app/config/collections/platform.php | 4 ++-- app/init/database/filters.php | 2 +- .../Platform/Modules/Insights/Http/Insights/Delete.php | 4 ++-- .../Modules/Insights/Http/Manager/Insights/Create.php | 2 +- .../Platform/Modules/Insights/Http/Reports/Delete.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/config/collections/platform.php b/app/config/collections/platform.php index ea65759876..db6bc29d10 100644 --- a/app/config/collections/platform.php +++ b/app/config/collections/platform.php @@ -2369,9 +2369,9 @@ $platformCollections = [ ], ], - 'ctas' => [ + 'insightCTAs' => [ '$collection' => ID::custom(Database::METADATA), - '$id' => ID::custom('ctas'), + '$id' => ID::custom('insightCTAs'), 'name' => 'Insight CTAs', 'attributes' => [ [ diff --git a/app/init/database/filters.php b/app/init/database/filters.php index 3d9a20a24b..f6afb28304 100644 --- a/app/init/database/filters.php +++ b/app/init/database/filters.php @@ -483,7 +483,7 @@ Database::addFilter( }, function (mixed $value, Document $document, Database $database) { return $database->getAuthorization()->skip(fn () => $database - ->find('ctas', [ + ->find('insightCTAs', [ Query::equal('insightInternalId', [$document->getSequence()]), Query::limit(APP_LIMIT_SUBQUERY), ])); diff --git a/src/Appwrite/Platform/Modules/Insights/Http/Insights/Delete.php b/src/Appwrite/Platform/Modules/Insights/Http/Insights/Delete.php index 2f7974b965..d8097f4126 100644 --- a/src/Appwrite/Platform/Modules/Insights/Http/Insights/Delete.php +++ b/src/Appwrite/Platform/Modules/Insights/Http/Insights/Delete.php @@ -78,13 +78,13 @@ class Delete extends Action } // Cascade delete child CTAs first. - $childCTAs = $dbForPlatform->find('ctas', [ + $childCTAs = $dbForPlatform->find('insightCTAs', [ Query::equal('insightInternalId', [$insight->getSequence()]), Query::limit(APP_LIMIT_COUNT), ]); foreach ($childCTAs as $cta) { - $dbForPlatform->deleteDocument('ctas', $cta->getId()); + $dbForPlatform->deleteDocument('insightCTAs', $cta->getId()); } if (!$dbForPlatform->deleteDocument('insights', $insight->getId())) { diff --git a/src/Appwrite/Platform/Modules/Insights/Http/Manager/Insights/Create.php b/src/Appwrite/Platform/Modules/Insights/Http/Manager/Insights/Create.php index 6455899638..1688867a6f 100644 --- a/src/Appwrite/Platform/Modules/Insights/Http/Manager/Insights/Create.php +++ b/src/Appwrite/Platform/Modules/Insights/Http/Manager/Insights/Create.php @@ -176,7 +176,7 @@ class Create extends Action } foreach ($normalizedCTAs as $cta) { - $dbForPlatform->createDocument('ctas', new Document([ + $dbForPlatform->createDocument('insightCTAs', new Document([ '$id' => ID::unique(), 'projectInternalId' => $project->getSequence(), 'projectId' => $project->getId(), diff --git a/src/Appwrite/Platform/Modules/Insights/Http/Reports/Delete.php b/src/Appwrite/Platform/Modules/Insights/Http/Reports/Delete.php index 5560d3060c..81bc5bf12d 100644 --- a/src/Appwrite/Platform/Modules/Insights/Http/Reports/Delete.php +++ b/src/Appwrite/Platform/Modules/Insights/Http/Reports/Delete.php @@ -85,12 +85,12 @@ class Delete extends Action foreach ($childInsights as $insight) { // Cascade through CTAs first. - $childCTAs = $dbForPlatform->find('ctas', [ + $childCTAs = $dbForPlatform->find('insightCTAs', [ Query::equal('insightInternalId', [$insight->getSequence()]), Query::limit(APP_LIMIT_COUNT), ]); foreach ($childCTAs as $cta) { - $dbForPlatform->deleteDocument('ctas', $cta->getId()); + $dbForPlatform->deleteDocument('insightCTAs', $cta->getId()); } $dbForPlatform->deleteDocument('insights', $insight->getId());