Форматирование

This commit is contained in:
brusnitsyn
2026-04-24 16:46:10 +09:00
parent fd0e6ee817
commit 63daa62888
87 changed files with 1380 additions and 791 deletions

View File

@@ -1,18 +1,19 @@
<?php
// app/Services/Base/BaseMetricService.php
namespace App\Services\Base;
use App\Contracts\MetricCalculatorInterface;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
abstract class BaseMetricService
{
protected array $cache = [];
protected array $config = [];
abstract protected function getMetricId(): int;
abstract protected function calculate(array $departmentIds, string $startDate, string $endDate): array;
public function getCached(array $departmentIds, string $startDate, string $endDate): array
@@ -26,16 +27,18 @@ abstract class BaseMetricService
try {
$result = $this->calculate($departmentIds, $startDate, $endDate);
$this->cache[$cacheKey] = $result;
return $result;
} catch (\Exception $e) {
Log::error("Error in " . static::class . ": " . $e->getMessage());
Log::error('Error in '.static::class.': '.$e->getMessage());
return array_fill_keys($departmentIds, 0);
}
}
protected function getCacheKey(array $departmentIds, string $startDate, string $endDate): string
{
return static::class . '_' . md5(implode(',', $departmentIds) . $startDate . $endDate);
return static::class.'_'.md5(implode(',', $departmentIds).$startDate.$endDate);
}
public function clearCache(): void