refactor: replace queries with cached versions for performance improvements

This commit is contained in:
Andras Bacsai
2025-12-08 13:39:33 +01:00
parent bb83f4e5c3
commit 5e8d11f732
28 changed files with 305 additions and 125 deletions

View File

@@ -44,11 +44,25 @@ class StandaloneClickhouse extends BaseModel
});
}
/**
* Get query builder for ClickHouse databases owned by current team.
* If you need all databases without further query chaining, use ownedByCurrentTeamCached() instead.
*/
public static function ownedByCurrentTeam()
{
return StandaloneClickhouse::whereRelation('environment.project.team', 'id', currentTeam()->id)->orderBy('name');
}
/**
* Get all ClickHouse databases owned by current team (cached for request duration).
*/
public static function ownedByCurrentTeamCached()
{
return once(function () {
return StandaloneClickhouse::ownedByCurrentTeam()->get();
});
}
protected function serverStatus(): Attribute
{
return Attribute::make(