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

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

@@ -33,6 +33,7 @@ class ClearStatisticsCache extends Command
// Очищаем весь кэш статистики
$this->clearAllStatisticsCache();
$this->info('✅ Весь кэш статистики очищен');
return 0;
}
@@ -40,6 +41,7 @@ class ClearStatisticsCache extends Command
// Очищаем кэш для конкретного отделения
$this->clearDepartmentCache($departmentId);
$this->info("✅ Кэш статистики для отдела {$departmentId} очищен");
return 0;
}
@@ -47,11 +49,13 @@ class ClearStatisticsCache extends Command
// Очищаем кэш за конкретную дату
$this->clearDateCache($date);
$this->info("✅ Кэш статистики за {$date} очищен");
return 0;
}
// Если опции не указаны, показываем помощь
$this->showHelp();
return 1;
}
@@ -69,7 +73,7 @@ class ClearStatisticsCache extends Command
$this->clearStatisticsKeys();
}
$this->info("Очищено: весь кэш статистики");
$this->info('Очищено: весь кэш статистики');
}
/**
@@ -78,14 +82,14 @@ class ClearStatisticsCache extends Command
private function clearDepartmentCache(int $departmentId): void
{
if (method_exists(Cache::store(), 'tags')) {
Cache::tags(['statistics', 'department_' . $departmentId])->flush();
Cache::tags(['statistics', 'department_'.$departmentId])->flush();
} else {
// Ищем и удаляем ключи для отдела
$keys = Cache::get('statistics_keys_' . $departmentId, []);
$keys = Cache::get('statistics_keys_'.$departmentId, []);
foreach ($keys as $key) {
Cache::forget($key);
}
Cache::forget('statistics_keys_' . $departmentId);
Cache::forget('statistics_keys_'.$departmentId);
}
$this->info("Очищено: кэш для отдела {$departmentId}");
@@ -97,7 +101,7 @@ class ClearStatisticsCache extends Command
private function clearDateCache(string $date): void
{
if (method_exists(Cache::store(), 'tags')) {
Cache::tags(['statistics', 'date_' . $date])->flush();
Cache::tags(['statistics', 'date_'.$date])->flush();
} else {
// Ищем ключи с этой датой
$prefix = config('cache.prefix', 'laravel');
@@ -119,9 +123,9 @@ class ClearStatisticsCache extends Command
$redis = $store->getRedis();
$keys = $redis->keys($pattern);
if (!empty($keys)) {
if (! empty($keys)) {
$redis->del($keys);
$this->info("Удалено ключей: " . count($keys));
$this->info('Удалено ключей: '.count($keys));
}
}
}
@@ -139,9 +143,9 @@ class ClearStatisticsCache extends Command
$redis = $store->getRedis();
$keys = $redis->keys("{$prefix}:statistics:*");
if (!empty($keys)) {
if (! empty($keys)) {
$redis->del($keys);
$this->info("Удалено ключей статистики: " . count($keys));
$this->info('Удалено ключей статистики: '.count($keys));
}
}
// Для файлового кэша
@@ -156,11 +160,11 @@ class ClearStatisticsCache extends Command
*/
private function clearFileCache(string $directory, string $pattern): void
{
if (!is_dir($directory)) {
if (! is_dir($directory)) {
return;
}
$files = glob($directory . '/*');
$files = glob($directory.'/*');
$deleted = 0;
foreach ($files as $file) {
@@ -173,7 +177,7 @@ class ClearStatisticsCache extends Command
}
}
$this->info("Удалено файлов кэша: " . $deleted);
$this->info('Удалено файлов кэша: '.$deleted);
}
/**