<commit_before># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from configman import Namespace
from crontabber.base import BaseCronApp
from crontabber.mixins import (
    with_postgres_transactions,
    with_single_postgres_transaction,
)


@with_postgres_transactions()
@with_single_postgres_transaction()
class TruncatePartitionsCronApp(BaseCronApp):
    app_name = 'truncate-partitions'
    app_version = '1.0'
    app_description = """See
    http://socorro.readthedocs.org/en/latest/development
    /databaseadminfunctions.html#truncate-partitions
    See https://bugzilla.mozilla.org/show_bug.cgi?id=1117911
    """
    required_config = Namespace()
    required_config.add_option(
        'weeks_to_keep',
        default=26, # default to 6 months
        doc='Number of weeks of raw crash data to keep in Postgres')

    def run(self, connection):
        cursor = connection.cursor()<commit_msg>fixes bug 1191006 - truncate partitions more aggressively<commit_after># This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from configman import Namespace
from crontabber.base import BaseCronApp
from crontabber.mixins import (
    with_postgres_transactions,
    with_single_postgres_transaction,
)


@with_postgres_transactions()
@with_single_postgres_transaction()
class TruncatePartitionsCronApp(BaseCronApp):
    app_name = 'truncate-partitions'
    app_version = '1.0'
    app_description = """See
    http://socorro.readthedocs.org/en/latest/development
    /databaseadminfunctions.html#truncate-partitions
    See https://bugzilla.mozilla.org/show_bug.cgi?id=1117911
    """
    required_config = Namespace()
    required_config.add_option(
        'weeks_to_keep',
        default=2,  # 2 weeks is sufficient for a backfill range if need be
        doc='Number of weeks of raw crash data to keep in Postgres')

    def run(self, connection):
        cursor = connection.cursor()
{'fraction_non_alphanumeric': 0.0863013698630137, 'fraction_numerical': 0.017351598173515982, 'mean_word_length': 3.9235955056179774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5145624', 'n_tokens_mistral': 713, 'n_tokens_neox': 663, 'n_words': 186}