Skip to content

Commit

Permalink
Performance optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivopetkov committed Jun 20, 2018
1 parent 9aa2dcf commit 32085cf
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/App/DataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,24 @@ public function getList(): \BearFramework\DataList
foreach ($context->filterByProperties as $filter) {
$whereOptions[] = [$filter->property, $filter->value, $filter->operator];
}
$resultKeys = ['key', 'body', 'metadata'];
if (isset($context->requestedProperties) && !empty($context->requestedProperties)) {
$resultKeys = ['key'];
foreach ($context->requestedProperties as $requestedProperty) {
if ($requestedProperty === 'value') {
$resultKeys[] = 'body';
} elseif ($requestedProperty === 'metadata') {
$resultKeys[] = 'metadata';
}
}
$resultKeys = array_unique($resultKeys);
}

$result = $this->execute([
[
'command' => 'search',
'where' => $whereOptions,
'result' => ['key', 'body', 'metadata']
'result' => $resultKeys
]
]);
$list = [];
Expand Down Expand Up @@ -659,7 +672,7 @@ public function getFilename(string $key): string
*/
private function makeDataItemFromRawData(array $rawData): \BearFramework\App\DataItem
{
$dataItem = $this->make($rawData['key'], $rawData['body']);
$dataItem = $this->make(isset($rawData['key']) ? $rawData['key'] : null, isset($rawData['body']) ? $rawData['body'] : null);
foreach ($rawData as $name => $value) {
if (strpos($name, 'metadata.') === 0) {
$name = substr($name, 9);
Expand Down

0 comments on commit 32085cf

Please sign in to comment.