mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-09-02 08:09:19 +08:00
Add error handling to default subpanel statistic
- Check if queries is empty -- Return error statistic -- Add logging
This commit is contained in:
parent
4bda1b7771
commit
cc79d2e375
1 changed files with 22 additions and 1 deletions
|
@ -5,13 +5,20 @@ namespace App\Legacy\Statistics;
|
|||
use App\Entity\Statistic;
|
||||
use App\Legacy\Data\PresetDataHandlers\SubpanelDataQueryHandler;
|
||||
use App\Service\StatisticsProviderInterface;
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class SubpanelDefault extends SubpanelDataQueryHandler implements StatisticsProviderInterface
|
||||
class SubpanelDefault extends SubpanelDataQueryHandler implements StatisticsProviderInterface, LoggerAwareInterface
|
||||
{
|
||||
use StatisticsHandlingTrait;
|
||||
|
||||
public const KEY = 'default';
|
||||
|
||||
/**
|
||||
* @var LoggerInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
@ -38,6 +45,12 @@ class SubpanelDefault extends SubpanelDataQueryHandler implements StatisticsProv
|
|||
|
||||
$queries = $this->getQueries($module, $id, $subpanel);
|
||||
|
||||
if (empty($queries)) {
|
||||
$this->logger->error('default-statistic: No queries found.', ['query' => $query]);
|
||||
|
||||
return $this->getErrorResponse(self::KEY);
|
||||
}
|
||||
|
||||
$parts = $queries[0];
|
||||
$parts['select'] = 'SELECT COUNT(*) as value';
|
||||
|
||||
|
@ -50,4 +63,12 @@ class SubpanelDefault extends SubpanelDataQueryHandler implements StatisticsProv
|
|||
|
||||
return $statistic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue