-
Notifications
You must be signed in to change notification settings - Fork 9
Fix: public methods #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request changes the audit batch API to return a boolean success flag instead of an array of created Log objects. The abstract Adapter::createBatch signature and implementations (ClickHouse, Database) now return bool. Audit::logBatch likewise returns bool. Database adapter now maps input logs to Document instances and calls createDocuments without returning per-log results; several Query::orderAsc/Desc calls were changed to omit the 'time' field. The SQL adapter raises visibility of five helper methods from protected to public. Tests were updated to assert truthiness of batch calls instead of examining returned arrays. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
src/Audit/Adapter.php(1 hunks)src/Audit/Adapter/ClickHouse.php(2 hunks)src/Audit/Adapter/Database.php(5 hunks)src/Audit/Adapter/SQL.php(5 hunks)src/Audit/Audit.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/Audit/Adapter/ClickHouse.php (2)
src/Audit/Adapter/Database.php (1)
createBatch(87-103)src/Audit/Adapter.php (1)
createBatch(62-62)
src/Audit/Adapter/Database.php (4)
src/Audit/Adapter.php (1)
createBatch(62-62)src/Audit/Adapter/ClickHouse.php (1)
createBatch(503-583)src/Audit/Audit.php (1)
log(61-72)src/Audit/Adapter/SQL.php (1)
getCollectionName(24-27)
src/Audit/Adapter.php (2)
src/Audit/Adapter/Database.php (1)
createBatch(87-103)src/Audit/Adapter/ClickHouse.php (1)
createBatch(503-583)
🪛 GitHub Actions: CodeQL
src/Audit/Adapter/Database.php
[error] 87-87: PHPStan: @return tag indicates 'array<Utopia\Audit\Log>' but function return type is bool. This is incompatible (return type mismatch in PHPDoc).
🔇 Additional comments (9)
src/Audit/Adapter.php (1)
58-62: LGTM! Breaking API change to simplify batch logging.The method signature change from returning
array<Log>toboolsimplifies the batch creation API by returning a success indicator instead of created log entries. This aligns with the PR objectives to fix batch logging.src/Audit/Adapter/ClickHouse.php (1)
503-582: LGTM! Batch creation simplified to return boolean status.The implementation correctly aligns with the updated interface, returning
trueafter successful batch insertion instead of constructing and returning Log objects. The early return for empty logs is appropriate.src/Audit/Audit.php (1)
78-84: LGTM! Public API updated consistently with adapter changes.The
logBatchmethod signature correctly updated to returnbool, maintaining simple delegation to the adapter'screateBatchmethod.src/Audit/Adapter/Database.php (5)
87-103: LGTM! Batch creation simplified with consistent boolean return.The refactored implementation correctly transforms logs into Document instances via
array_mapand creates them in a single batch operation, returningtrueto indicate success.
210-210: Verify that removing the 'time' field parameter maintains correct ordering.Same concern as Line 154 - ensure
Query::orderAsc()without the field parameter maintains time-based ordering.
271-271: Verify that removing the 'time' field parameter maintains correct ordering.Same concern as Line 154 - ensure
Query::orderAsc()without the field parameter maintains time-based ordering.
335-335: Verify that removing the 'time' field parameter maintains correct ordering.Same concern as Line 154 - ensure
Query::orderAsc()without the field parameter maintains time-based ordering.
154-154: The Utopia Database Query builder'sorderAsc()andorderDesc()methods implicitly default to the time field when used without parameters. This is verified by the test suite, which confirms that ordering produces correct chronological results (newest first withorderDesc, oldest first withorderAsc). The deliberate removal of the explicit 'time' parameter in commit 4f77e21 was a fix, not a regression, as the framework handles field selection automatically in this context.src/Audit/Adapter/SQL.php (1)
24-24: LGTM! Visibility broadened to expose metadata accessors.Five utility methods (
getCollectionName,getAttributes,getAttributeDocuments,getIndexes,getIndexDocuments) changed from protected to public, allowing external access to audit log metadata. This aligns with the PR title "Fix: public methods" and enables consistent access across adapters.Also applies to: 43-43, 127-127, 142-142, 173-173
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/Audit/Adapter/Database.php(5 hunks)tests/Audit/Adapter/ClickHouseTest.php(1 hunks)tests/Audit/AuditBase.php(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Audit/Adapter/Database.php
🧰 Additional context used
🪛 GitHub Actions: Tests
tests/Audit/AuditBase.php
[error] 218-218: Test failure: Utopia\Tests\Audit\Adapter\ClickHouseTest::testLogByBatch - Expected value to be of type 'array', but got 'boolean'. Command: docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests
[error] 218-218: Test failure: Utopia\Tests\Audit\Adapter\DatabaseTest::testLogByBatch - Expected value to be of type 'array', but got 'boolean'. Command: docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests
🔇 Additional comments (1)
tests/Audit/Adapter/ClickHouseTest.php (1)
312-313: LGTM - correctly updated for boolean return type.The assertion properly validates that
logBatchreturns a truthy boolean value, consistent with the API changes in this PR.
Fix: public methods
Summary by CodeRabbit
Breaking Changes
Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.