Commit Graph

56 Commits

Author SHA1 Message Date
Jake Barnby b058eb31f4 (refactor): inline CTAs as JSON on insights collection 2026-05-13 17:10:33 +12:00
Jake Barnby 304b0dab35 (fix): address greptile P1 review comments
- Add skipFilters to Reports/Get.php (was the only endpoint still
  triggering the full N+1 subquery cascade)
- Scale CTA batch limit dynamically (insightCount * MAX_CTA_COUNT)
  instead of fixed APP_LIMIT_SUBQUERY to prevent silent truncation
- Revert deleteReport to callback-based pagination so CTAs are not
  orphaned when a report has more than APP_LIMIT_SUBQUERY insights
- Add explicit prefix lengths (700) to _key_project_resource and
  _key_project_parent_resource indexes to stay under InnoDB 3072-byte limit
- Validate CTA service/method against ADVISOR_CTA_SERVICES and
  ADVISOR_CTA_METHODS enums in the CTAs validator

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-13 01:42:59 +12:00
Jake Barnby 9da4a3260d (refactor): improve advisor module perf, security, and maintainability
- Fix N+1 in Reports/XList (51→4 queries) via skipFilters + batch fetch
- Add skipFilters to Reports/Delete and cursor fetch (avoid loading all
  nested insights/CTAs just for ownership check)
- Fix N+1 in deleteReport worker (flat CTA deletion instead of per-insight)
- Add advisor entity cleanup on project deletion (reports, insights, CTAs)
- Remove resourceInternalId, parentResourceInternalId, $permissions from
  Insight response model (internal IDs leak DB internals, permissions unused)
- Remove dead subQueryInsightCTAs filter registration
- Remove stale enum-value comments from platform schema
- Fix _key_dismissedAt index to include projectInternalId
- Fix scope category from 'Other' to 'Advisor'
- Switch action base class from Utopia\Platform\Action to Appwrite\Platform\Action

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-13 01:13:37 +12:00
Jake Barnby f9ff1166b9 (perf): batch-fetch CTAs across an insight set to collapse N+1 2026-05-12 23:24:26 +12:00
copilot-swe-agent[bot] 6d0eab2583 refactor(advisor): make insights API read-only in CE
Agent-Logs-Url: https://github.com/appwrite/appwrite/sessions/8d7897b5-ac68-487d-954a-be717380bf66

Co-authored-by: abnegate <5857008+abnegate@users.noreply.github.com>
2026-05-08 06:07:23 +00:00
Jake Barnby 6c6782dd28 Merge remote-tracking branch 'origin/1.9.x' into pr-12194-feat-insights-module
# Conflicts:
#	app/config/scopes/project.php
2026-05-06 20:33:40 +12:00
Jake Barnby c5dfc42a60 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) <noreply@anthropic.com>
2026-05-06 18:12:17 +12:00
Jake Barnby 5404bfec75 refactor(insights): promote CTAs to own collection with backref
Embedding CTAs as a 16384-byte JSON blob on `insights` was the wrong
shape — they're real documents with their own lifecycle. Move them out.

Schema:
- New platform `ctas` collection. Each row carries `projectInternalId`,
  `projectId`, `insightInternalId`, `insightId` (backref), plus the
  CTA fields: `key`, `label`, `service`, `method`, `params`.
- Indexes: `(projectInternalId, insightInternalId)` for the subquery
  lookup and a UNIQUE `(insightInternalId, key)` so the per-insight
  uniqueness invariant lives at the DB layer (not just in PHP).
- The `ctas` field on `insights` becomes a virtual attribute backed by
  a new `subQueryInsightCTAs` filter that joins child docs at read
  time. Consumers still get CTAs embedded on the insight response —
  one round-trip from their perspective.
- The CTA descriptor's within-insight identifier renamed `id` → `key`
  (clashed with the document `$id`). Validator updated.

Endpoints:
- Manager Create now persists CTAs as separate `ctas` documents after
  the parent insight, then re-fetches the insight so the response
  carries the freshly-joined CTA list.
- User Update trimmed to user-controlled state only (`severity`,
  `status`). `title`, `summary`, `payload`, `ctas`, and `analyzedAt`
  are analyzer-controlled — analyzers re-ingest by deleting and
  POSTing again to the manager endpoint.
- Insight Delete cascades to CTAs.
- Report Delete cascades through Insights → CTAs.

Response model:
- InsightCTA gains the standard document headers (`$id`,
  `$createdAt`, `$updatedAt`) and an `insightId` backref. The
  caller-supplied identifier is now `key`.

Tests:
- E2E sampleCTA factory uses `key` everywhere; testCreate asserts the
  freshly-created CTA carries `$id`, `$createdAt`, `insightId`, and
  the right shape.
- Dropped the testUpdate*CTA* tests — user Update no longer accepts
  CTAs. testDismissViaUpdate now depends on testUpdate directly.
- Unit tests rewritten to validate `key` instead of `id`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 18:07:49 +12:00
ArnabChatterjee20k 928aa9c909 Merge branch '1.9.x' into big-int 2026-04-09 14:43:51 +05:30
Damodar Lohani f315e759f3 fix: map deprecated platform types in subQueryPlatforms filter
The subQueryPlatforms database filter loads platforms as a sub-attribute
when project documents are fetched. Old platform type values stored in
the database (e.g. flutter-android, flutter-ios) were not being mapped
to the new consolidated types before being included in the project
response sent to the frontend/console.

This adds Platform::mapDeprecatedType() to the filter so all platforms
returned as part of a project document have their types mapped
consistently, complementing the existing mapping in the dedicated
platform Get and List endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 08:31:39 +00:00
ArnabChatterjee20k 2fb54e0846 Add BigInt support with dedicated bigintRange format and update related logic 2026-03-30 18:59:24 +05:30
ArnabChatterjee20k dfbf22cf3c updated format 2026-03-30 18:36:19 +05:30
eldadfux aa89128d10 Fixes 2026-03-19 22:54:45 +01:00
ArnabChatterjee20k 8c579cf88d updated string filtering in the filters 2026-02-25 19:29:03 +05:30
Jake Barnby f13f80b2a3 fix: Handle unlimited attribute limit for MongoDB in subQueryAttributes filter
MongoDB adapter returns 0 from getLimitForAttributes() meaning unlimited,
but Query::limit(0) fails validation since minimum valid limit is 1.
Fall back to APP_LIMIT_SUBQUERY (1000) when adapter reports unlimited.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 00:55:05 +13:00
Matej Bačo 6ebc36d0f3 Fix merge conflict 2026-01-21 14:47:18 +01:00
Matej Bačo 1308706023 Merge branch '1.8.x' into chore-php-types 2026-01-15 15:52:51 +01:00
Jake Barnby 2cfb5ecfd9 Reapply "Merge pull request #11130 from appwrite/feat-auth-instance"
This reverts commit 38687bc24e.
2026-01-15 04:08:00 +13:00
Jake Barnby 38687bc24e Revert "Merge pull request #11130 from appwrite/feat-auth-instance"
This reverts commit c12cad80bb, reversing
changes made to 2a17429226.

# Conflicts:
#	composer.lock
2026-01-15 03:48:42 +13:00
Jake Barnby 5c915ef92f Reapply "Merge pull request #11099 from appwrite/feat-auth-instance"
This reverts commit 321fc8ee70.
2026-01-14 19:07:49 +13:00
Jake Barnby 321fc8ee70 Revert "Merge pull request #11099 from appwrite/feat-auth-instance"
This reverts commit a4734a5de7, reversing
changes made to 15922fb88c.

# Conflicts:
#	composer.lock
2026-01-14 02:37:17 +13:00
Matej Bačo 3d4b29e0f1 Merge branch '1.8.x' into chore-php-types 2026-01-10 16:42:38 +01:00
Jake Barnby 7573ee75a2 Use authorization instance 2026-01-07 20:04:28 +13:00
Hemachandar 3b5b15d1a6 Remove dual read for keys (#11083)
* Remove dual read for `keys`

* write to mock

* remove dual writes

* Revert "remove dual writes"

This reverts commit ce9a48423b.

* add todo
2026-01-06 17:49:32 +05:30
Hemachandar c1e50c7abd Write to new resource attributes in keys (#11003)
* Write to new resource attributes in `keys`

* temp for tests

* list keys

* add subqueries

* lint
2025-12-30 17:09:59 +05:30
Matej Bačo c0c1d693c2 DB schema update for keys 2025-12-23 13:06:25 +01:00
Matej Bačo d45d27b780 Merge branch '1.8.x' into chore-php-types 2025-12-19 16:06:46 +01:00
Jake Barnby dc85d44647 Revert "Refactor auth single instance" 2025-12-20 02:54:50 +13:00
Matej Bačo 69d5ce0f55 Switch over to resource-based key DB structure 2025-12-19 13:40:32 +01:00
shimon cee9906073 reverting the revert 2025-11-26 12:27:57 +02:00
shimon 4ad249f918 Revert "Revert "Merge pull request #10682 from appwrite/refactor-auth-single-instance""
This reverts commit 8765d5650a.
2025-11-26 12:05:12 +02:00
Jake Barnby 8765d5650a Revert "Merge pull request #10682 from appwrite/refactor-auth-single-instance"
This reverts commit 919b01a1b1, reversing
changes made to deb5039352.
2025-11-19 16:21:06 +13:00
shimon 8b3b07a710 linter 2025-10-22 16:40:00 +03:00
shimon 33f88fa5e0 Refactor authorization handling across multiple modules to use the new getAuthorization() method. Update CHANGES.md to reflect the change in usage worker authorization. Adjust composer.json to specify the correct version for utopia-php/database. Update plugin-api-version in composer.lock. 2025-10-22 16:35:48 +03:00
fogelito 4da7f04a5c Add order by 2025-09-18 10:58:27 +03:00
fogelito a7e9e58312 Add order by 2025-09-18 10:57:47 +03:00
Matej Bačo 14faef323c Fix variables sharing across resources 2025-08-12 17:01:13 +02:00
Jake Barnby dd25072cdf Merge pull request #9868 from ArnabChatterjee20k/dat-532
added encrypt property in the attribute string response model
# Conflicts:
#	tests/e2e/Services/Databases/DatabasesCustomServerTest.php
2025-05-27 13:57:51 +12:00
Jake Barnby 3158c15111 Merge remote-tracking branch 'origin/1.7.x' into 1.8.x
# Conflicts:
#	app/controllers/api/functions.php
#	app/controllers/api/project.php
#	app/controllers/api/proxy.php
#	app/controllers/api/storage.php
#	app/controllers/api/vcs.php
#	app/controllers/general.php
#	app/controllers/shared/api.php
#	app/init/database/filters.php
#	composer.json
#	composer.lock
#	src/Appwrite/Migration/Migration.php
#	src/Appwrite/Migration/Version/V15.php
#	src/Appwrite/Migration/Version/V16.php
#	src/Appwrite/Migration/Version/V17.php
#	src/Appwrite/Migration/Version/V18.php
#	src/Appwrite/Migration/Version/V19.php
#	src/Appwrite/Migration/Version/V20.php
#	src/Appwrite/Migration/Version/V21.php
#	src/Appwrite/Platform/Tasks/Migrate.php
#	src/Appwrite/Platform/Workers/Builds.php
#	src/Appwrite/Platform/Workers/Deletes.php
#	src/Appwrite/Platform/Workers/Functions.php
#	src/Appwrite/Platform/Workers/StatsResources.php
#	src/Appwrite/Platform/Workers/StatsUsage.php
2025-05-27 13:36:23 +12:00
Jake Barnby ab97b7cc54 Merge pull request #9877 from appwrite/revert-9871-feat-sync
Revert "Feat sync encrypt updates"
2025-05-26 21:37:41 +12:00
Jake Barnby 86f7489640 Internal ID -> sequence 2025-05-26 17:42:11 +12:00
Jake Barnby a616aa0e93 Revert "Merge pull request #9877 from appwrite/revert-9871-feat-sync"
This reverts commit 1a0e82b4e4, reversing
changes made to 8bc5117259.
2025-05-26 17:36:55 +12:00
Christy Jacob 28d2ed1baa Revert "Feat sequence" 2025-05-23 21:39:56 +04:00
Jake Barnby 70feb72de0 Revert "Feat sync encrypt updates" 2025-05-24 03:04:46 +12:00
Jake Barnby 1a2a725cb0 Merge pull request #9868 from ArnabChatterjee20k/dat-532
added encrypt property in the attribute string response model
2025-05-23 23:53:23 +12:00
Darshan a413a613f5 Merge branch 'main' into feat-sequence 2025-05-23 15:35:39 +05:30
ArnabChatterjee20k e586afceb7 updates 2025-05-23 14:11:57 +05:30
ArnabChatterjee20k 6ea3593921 updated collection filter 2025-05-23 13:40:56 +05:30
Jake Barnby 04a9b0be34 Fix replace 2025-05-23 03:29:44 +12:00
Jake Barnby 71e3446498 Change internal ID to sequence 2025-05-23 02:55:29 +12:00