<commit_before>"""
Settings used when deployed on heroku
Not used directly - imported from production and staging settings
"""

# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

# MuckRock
from muckrock.settings.base import *

# media and static asset handling
DEFAULT_FILE_STORAGE = "muckrock.core.storage.MediaRootS3BotoStorage"
DIET_STORAGE = "storages.backends.s3boto.S3BotoStorage"
DIET_CONFIG = os.path.join(SITE_ROOT, "../config/image_diet.yaml")
THUMBNAIL_DEFAULT_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = "muckrock.core.storage.CachedS3Boto3Storage"
COMPRESS_STORAGE = STATICFILES_STORAGE
AWS_S3_CUSTOM_DOMAIN = os.environ.get("CLOUDFRONT_DOMAIN")
if AWS_S3_CUSTOM_DOMAIN:
    STATIC_URL = "https://" + AWS_S3_CUSTOM_DOMAIN + "/"
else:
    STATIC_URL = "https://" + AWS_STORAGE_BUCKET_NAME + ".s3.amazonaws.com/"
COMPRESS_URL = STATIC_URL
MEDIA_URL = STATIC_URL + "media/"
CLEAN_S3_ON_FOIA_DELETE = True
USE_QUEUED_STORAGE = True
COMPRESS_ENABLED = True

TEMPLATES[0]["OPTIONS"]["loaders"] = [
    (
        "django.template.loaders.cached.Loader",
        [
            "django.template.loaders.filesystem.Loader",
            "django.template.loaders.app_directories.Loader",
        ],
    )
]
del TEMPLATES[0]["APP_DIRS"]

if "MEMCACHIER_SERVERS" in os.environ:
    os.environ["MEMCACHE_SERVERS"] = os.environ.get("MEMCACHIER_SERVERS", "").replace(
        ",", ";"
    )
    os.environ["MEMCACHE_USERNAME"] = os.environ.get("MEMCACHIER_USERNAME", "")
    os.environ["MEMCACHE_PASSWORD"] = os.environ.get("MEMCACHIER_PASSWORD", "")

    CACHES["default"] = {
        # Use pylibmc
        "BACKEND": "django_pylibmc.memcached.PyLibMCCache",
        # Use binary memcache protocol (needed for authentication)
        "BINARY": True,
        # TIMEOUT is not the connection timeout! It's the default expiration
        # timeout that should be applied to keys! Setting it to `None`
        # disables expiration.<commit_msg>quick fix for file overwrite<commit_after>"""
Settings used when deployed on heroku
Not used directly - imported from production and staging settings
"""

# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

# MuckRock
from muckrock.settings.base import *

# media and static asset handling
DEFAULT_FILE_STORAGE = "muckrock.core.storage.MediaRootS3BotoStorage"
DIET_STORAGE = "storages.backends.s3boto.S3BotoStorage"
DIET_CONFIG = os.path.join(SITE_ROOT, "../config/image_diet.yaml")
THUMBNAIL_DEFAULT_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
STATICFILES_STORAGE = "muckrock.core.storage.CachedS3Boto3Storage"
COMPRESS_STORAGE = STATICFILES_STORAGE
AWS_S3_CUSTOM_DOMAIN = os.environ.get("CLOUDFRONT_DOMAIN")
if AWS_S3_CUSTOM_DOMAIN:
    STATIC_URL = "https://" + AWS_S3_CUSTOM_DOMAIN + "/"
else:
    STATIC_URL = "https://" + AWS_STORAGE_BUCKET_NAME + ".s3.amazonaws.com/"
COMPRESS_URL = STATIC_URL
MEDIA_URL = STATIC_URL + "media/"
CLEAN_S3_ON_FOIA_DELETE = True
USE_QUEUED_STORAGE = True
COMPRESS_ENABLED = True
AWS_S3_FILE_OVERWRITE = False

TEMPLATES[0]["OPTIONS"]["loaders"] = [
    (
        "django.template.loaders.cached.Loader",
        [
            "django.template.loaders.filesystem.Loader",
            "django.template.loaders.app_directories.Loader",
        ],
    )
]
del TEMPLATES[0]["APP_DIRS"]

if "MEMCACHIER_SERVERS" in os.environ:
    os.environ["MEMCACHE_SERVERS"] = os.environ.get("MEMCACHIER_SERVERS", "").replace(
        ",", ";"
    )
    os.environ["MEMCACHE_USERNAME"] = os.environ.get("MEMCACHIER_USERNAME", "")
    os.environ["MEMCACHE_PASSWORD"] = os.environ.get("MEMCACHIER_PASSWORD", "")

    CACHES["default"] = {
        # Use pylibmc
        "BACKEND": "django_pylibmc.memcached.PyLibMCCache",
        # Use binary memcache protocol (needed for authentication)
        "BINARY": True,
        # TIMEOUT is not the connection timeout! It's the default expiration
        # timeout that should be applied to keys! Setting it to `None`
        # disables expiration.
{'fraction_non_alphanumeric': 0.11926605504587157, 'fraction_numerical': 0.008182494421026532, 'mean_word_length': 4.198453608247423, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '1654470', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1444, 'n_words': 243}