Feat: stats sites and functions runtimes and frameworks#10786
Feat: stats sites and functions runtimes and frameworks#10786lohanidamodar merged 2 commits into1.8.xfrom
Conversation
- Sites frameworks count - Functions runtimes count
📝 WalkthroughWalkthroughAdded two metric constants in app/init/constants.php: METRIC_FUNCTIONS_RUNTIME = 'functions.runtimes.{runtime}' and METRIC_SITES_FRAMEWORK = 'sites.frameworks.{framework}'. Updated src/Appwrite/Platform/Workers/StatsResources.php to aggregate counts per function runtime and per site framework while iterating documents, store those counts in temporary maps, and persist the aggregated metrics using the existing stats creation mechanism. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ 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 |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
✨ Benchmark results
⚡ Benchmark Comparison
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Appwrite/Platform/Workers/StatsResources.php (1)
404-443: Consider extracting the aggregation pattern.The framework counting logic mirrors the runtime counting pattern (lines 338-383). While the current implementation is correct and clear, you could reduce duplication by extracting a helper method:
private function countByAttribute( Database $dbForProject, string $collection, string $attribute, string $metricTemplate, string $region, array $queries = [] ): void { $counts = []; $this->foreachDocument($dbForProject, $collection, $queries, function (Document $doc) use ($attribute, &$counts) { $value = $doc->getAttribute($attribute); if (!empty($value)) { $counts[$value] = ($counts[$value] ?? 0) + 1; } }); foreach ($counts as $value => $count) { $this->createStatsDocuments($region, str_replace("{{$attribute}}", $value, $metricTemplate), $count); } }This is optional since the duplication is limited and the current approach is straightforward.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Appwrite/Platform/Workers/StatsResources.php(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Appwrite/Platform/Workers/StatsResources.php (2)
src/Appwrite/Platform/Action.php (1)
foreachDocument(49-108)src/Appwrite/Utopia/Response/Model/Document.php (1)
Document(8-115)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Benchmark
- GitHub Check: Setup & Build Appwrite Image
🔇 Additional comments (1)
src/Appwrite/Platform/Workers/StatsResources.php (1)
338-383: LGTM! Runtime counting implementation is correct.The runtime aggregation logic properly accumulates counts per runtime value and persists them using the existing stats infrastructure. The
!empty()check appropriately handles functions without a runtime attribute.
What does this PR do?
Preview:

Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist