2016-10-06 00:42:56 +02:00
|
|
|
import sys
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
from django.db import connection
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
2017-01-07 03:23:44 +01:00
|
|
|
from analytics.lib.counts import do_drop_all_analytics_tables
|
2016-10-06 00:42:56 +02:00
|
|
|
|
2017-01-07 03:23:44 +01:00
|
|
|
from typing import Any
|
2016-10-06 00:42:56 +02:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2017-01-07 03:23:44 +01:00
|
|
|
help = """Clear analytics tables."""
|
2016-10-06 00:42:56 +02:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
# type: (ArgumentParser) -> None
|
|
|
|
parser.add_argument('--force',
|
|
|
|
action='store_true',
|
2017-01-07 03:23:44 +01:00
|
|
|
help="Clear analytics tables.")
|
2016-10-06 00:42:56 +02:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
# type: (*Any, **Any) -> None
|
|
|
|
if options['force']:
|
2017-01-07 03:23:44 +01:00
|
|
|
do_drop_all_analytics_tables()
|
2016-10-06 00:42:56 +02:00
|
|
|
else:
|
|
|
|
print("Would delete all data from analytics tables (!); use --force to do so.")
|
|
|
|
sys.exit(1)
|