2017-11-16 00:43:27 +01:00
|
|
|
from argparse import ArgumentParser
|
2019-07-29 00:38:14 +02:00
|
|
|
from typing import Any, Optional
|
2016-06-04 16:52:18 +02:00
|
|
|
|
2013-01-14 17:51:18 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
2017-11-16 00:43:27 +01:00
|
|
|
|
|
|
|
from zerver.lib.cache_helpers import cache_fillers, fill_remote_cache
|
2013-01-14 17:51:18 +01:00
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2013-01-14 17:51:18 +01:00
|
|
|
class Command(BaseCommand):
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2022-03-25 23:37:10 +01:00
|
|
|
parser.add_argument(
|
|
|
|
"--cache", help="Populate one specific cache", choices=cache_fillers.keys()
|
|
|
|
)
|
2013-01-14 17:51:18 +01:00
|
|
|
|
2019-07-29 00:38:14 +02:00
|
|
|
def handle(self, *args: Any, **options: Optional[str]) -> None:
|
2013-03-26 17:24:02 +01:00
|
|
|
if options["cache"] is not None:
|
2016-06-04 16:52:18 +02:00
|
|
|
fill_remote_cache(options["cache"])
|
|
|
|
return
|
2013-03-26 17:24:02 +01:00
|
|
|
|
|
|
|
for cache in cache_fillers.keys():
|
2016-03-31 03:43:22 +02:00
|
|
|
fill_remote_cache(cache)
|