mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-18 01:20:31 +00:00
refactor: replace queries with cached versions for performance improvements
This commit is contained in:
@@ -338,11 +338,25 @@ class Application extends BaseModel
|
||||
return Application::whereRelation('environment.project.team', 'id', $teamId)->orderBy('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query builder for applications owned by current team.
|
||||
* If you need all applications without further query chaining, use ownedByCurrentTeamCached() instead.
|
||||
*/
|
||||
public static function ownedByCurrentTeam()
|
||||
{
|
||||
return Application::whereRelation('environment.project.team', 'id', currentTeam()->id)->orderBy('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all applications owned by current team (cached for request duration).
|
||||
*/
|
||||
public static function ownedByCurrentTeamCached()
|
||||
{
|
||||
return once(function () {
|
||||
return Application::ownedByCurrentTeam()->get();
|
||||
});
|
||||
}
|
||||
|
||||
public function getContainersToStop(Server $server, bool $previewDeployments = false): array
|
||||
{
|
||||
$containers = $previewDeployments
|
||||
|
||||
Reference in New Issue
Block a user