Добавил кеш к lyngsat
This commit is contained in:
0
dbapp/lyngsatapp/management/commands/__init__.py
Normal file
0
dbapp/lyngsatapp/management/commands/__init__.py
Normal file
40
dbapp/lyngsatapp/management/commands/clear_lyngsat_cache.py
Normal file
40
dbapp/lyngsatapp/management/commands/clear_lyngsat_cache.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Management команда для очистки кеша LyngSat.
|
||||
"""
|
||||
from django.core.management.base import BaseCommand
|
||||
from lyngsatapp.async_utils import clear_lyngsat_cache
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Очищает кеш данных LyngSat'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--type',
|
||||
type=str,
|
||||
default='all',
|
||||
choices=['regions', 'satellites', 'all'],
|
||||
help='Тип кеша для очистки (regions, satellites, all)'
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
cache_type = options['type']
|
||||
|
||||
self.stdout.write(f'Очистка кеша LyngSat: {cache_type}...')
|
||||
|
||||
stats = clear_lyngsat_cache(cache_type)
|
||||
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS(
|
||||
f'Кеш очищен успешно! Удалено записей: {stats["cleared"]}'
|
||||
)
|
||||
)
|
||||
|
||||
if stats['errors']:
|
||||
self.stdout.write(
|
||||
self.style.WARNING(
|
||||
f'Ошибок при очистке: {len(stats["errors"])}'
|
||||
)
|
||||
)
|
||||
for error in stats['errors']:
|
||||
self.stdout.write(self.style.ERROR(f' - {error}'))
|
||||
Reference in New Issue
Block a user