update: if/else > switch > match

This commit is contained in:
Darshan 2025-08-08 16:25:48 +05:30
parent 0556f8fdca
commit bc55639bf7
2 changed files with 9 additions and 19 deletions

View file

@ -106,18 +106,12 @@ class XList extends Action
]);
$audit = new Audit($dbForProject);
$isRows = $this->getContext() === ROWS;
// returns what we want, ignore the naming!
$type = $this->getCollectionsEventsContext();
$item = $isRows ? 'row' : 'document';
if (!$isRows) {
$resource = "database/$databaseId/$type/$collectionId/$item/{$document->getId()}";
} else {
// grid
$resource = "database/$databaseId/grid/$type/$collectionId/$item/{$document->getId()}";
}
$context = $this->getContext();
$resource = match ($context) {
ROWS => "database/$databaseId/grid/$type/$collectionId/$context/{$document->getId()}",
default => "database/$databaseId/$type/$collectionId/$context/{$document->getId()}",
};
$logs = $audit->getLogsByResource($resource, $queries);

View file

@ -103,15 +103,11 @@ class XList extends Action
]);
$audit = new Audit($dbForProject);
$context = $this->getContext();
$isTables = $context === TABLES;
if (!$isTables) {
$resource = "database/$databaseId/$context/$collectionId";
} else {
$resource = "database/$databaseId/grid/$context/$collectionId";
}
$resource = match ($context) {
TABLES => "database/$databaseId/grid/$context/$collectionId",
default => "database/$databaseId/$context/$collectionId",
};
$logs = $audit->getLogsByResource($resource, $queries);