Fix release from #1860 (hotfix #1934).

- Cron job to send weekly email report is processed multiple times. Review scheduling process to send to only one worker.
- Implement mechanism to ensure each email is sent only once to each recipient.
- Improve the way the async task is processed by creating a separate task for each organization, instead of processing all organizations in a single task.
posthog/settings.py
f'The environment vars "DATABASE_URL" or "POSTHOG_DB_NAME" are absolutely required to run this software'
    )
# Broker
# The last case happens when someone upgrades Heroku but doesn't have Redis installed yet. Collectstatic gets called before we can provision Redis.
if TEST or DEBUG or (len(sys.argv) > 1 and sys.argv[1] == "collectstatic"):
    REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost/")
else:
    REDIS_URL = os.environ.get("REDIS_URL", "")
if not REDIS_URL and os.environ.get("POSTHOG_REDIS_HOST", ""):
    REDIS_URL = "redis://:{}@{}:{}/".format(
        os.environ.get("POSTHOG_REDIS_PASSWORD", ""),
        os.environ.get("POSTHOG_REDIS_HOST", ""),
        os.environ.get("POSTHOG_REDIS_PORT", "6379"),
    )
if not REDIS_URL:
    raise ImproperlyConfigured(
        "Env var REDIS_URL or POSTHOG_REDIS_HOST is absolutely required to run this software.\n"
        "If upgrading from PostHog 1.0.10 or earlier, see here: "
        "https://posthog.com/docs/deployment/upgrading-posthog#upgrading-from-before-1011"
    )
CELERY_IMPORTS = ["posthog.tasks.webhooks"]  # required to avoid circular import
CELERY_BROKER_URL = REDIS_URL  # celery connects to redis
CELERY_BEAT_MAX_LOOP_INTERVAL = 30  # sleep max 30sec before checking for new periodic events
CELERY_RESULT_BACKEND = REDIS_URL  # stores results for lookup when processing
REDBEAT_LOCK_TIMEOUT = 45  # keep distributed beat lock for 45sec
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
    {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
]