mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-30 04:20:38 +00:00
refactor: replace queries with cached versions for performance improvements
This commit is contained in:
@@ -45,11 +45,25 @@ class StandaloneMariadb extends BaseModel
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query builder for MariaDB databases owned by current team.
|
||||
* If you need all databases without further query chaining, use ownedByCurrentTeamCached() instead.
|
||||
*/
|
||||
public static function ownedByCurrentTeam()
|
||||
{
|
||||
return StandaloneMariadb::whereRelation('environment.project.team', 'id', currentTeam()->id)->orderBy('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all MariaDB databases owned by current team (cached for request duration).
|
||||
*/
|
||||
public static function ownedByCurrentTeamCached()
|
||||
{
|
||||
return once(function () {
|
||||
return StandaloneMariadb::ownedByCurrentTeam()->get();
|
||||
});
|
||||
}
|
||||
|
||||
protected function serverStatus(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
|
||||
Reference in New Issue
Block a user