<commit_before>from django.core.management.base import BaseCommand
from datetime import date, timedelta
import logging

from logical.models import Database
from system.models import Configuration


LOG = logging.getLogger(__name__)


class Command(BaseCommand):
    '''
        remove database automatically when quarantine date expired
    '''

    def handle(self, *args, **options):
        quarantine_time = Configuration.get_by_name_as_int('quarantine_retention_days')
        quarantine_time_dt = date.today() - timedelta(days=quarantine_time)
        databases = Database.objects.filter(is_in_quarantine=True, quarantine_dt__lte=quarantine_time_dt)
        for database in databases:
            database.delete()
            LOG.info("The database %s was deleted, because it was set to quarentine %d days ago" % (database.name, quarantine_time))<commit_msg>moved to database models<commit_after>from django.core.management.base import BaseCommand
import logging

from logical.models import Database


LOG = logging.getLogger(__name__)


class Command(BaseCommand):
    '''
        remove database automatically when quarantine date expired
    '''

    def handle(self, *args, **options):
        Database.purge_quarantine()
{'fraction_non_alphanumeric': 0.08116883116883117, 'fraction_numerical': 0.0, 'mean_word_length': 4.180672268907563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2365701', 'n_tokens_mistral': 338, 'n_tokens_neox': 328, 'n_words': 91}