mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 00:14:24 +00:00
refactor: replace queries with cached versions for performance improvements
This commit is contained in:
1 parent
bb83f4e5c3
commit
5e8d11f732
28 files changed
+305
-125
No files matched your search
@@ -80,6 +80,10 @@ class PrivateKey extends BaseModel
|
||||
return self::extractPublicKeyFromPrivate($this->private_key) ?? 'Error loading private key';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query builder for private keys owned by current team.
|
||||
* If you need all private keys without further query chaining, use ownedByCurrentTeamCached() instead.
|
||||
*/
|
||||
public static function ownedByCurrentTeam(array $select = ['*'])
|
||||
{
|
||||
$teamId = currentTeam()->id;
|
||||
@@ -88,6 +92,16 @@ class PrivateKey extends BaseModel
|
||||
return self::whereTeamId($teamId)->select($selectArray->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all private keys owned by current team (cached for request duration).
|
||||
*/
|
||||
public static function ownedByCurrentTeamCached()
|
||||
{
|
||||
return once(function () {
|
||||
return PrivateKey::ownedByCurrentTeam()->get();
|
||||
});
|
||||
}
|
||||
|
||||
public static function ownedAndOnlySShKeys(array $select = ['*'])
|
||||
{
|
||||
$teamId = currentTeam()->id;
|
||||
|
||||
Reference in new issue
Block a user