Beispiel #1
0
def fetch_all_inbox_messages():
    """
    Fetches all unsolicited inbox messages (type="I") into InboxMessage
    """
    logger.info("Starting inbox message fetch for all orgs...")
    for org in Org.objects.filter(is_active=True):
        run_org_task(org, fetch_inbox_messages)
Beispiel #2
0
def sync_all_contacts():
    """
    Syncs all contacts for all orgs
    """
    logger.info("Starting contact sync for all orgs...")
    for org in Org.objects.filter(is_active=True):
        run_org_task(org, sync_org_contacts)
Beispiel #3
0
def fetch_all_runs():
    """Fetches flow runs for all orgs."""
    redis_connection = get_redis_connection()

    # only do this if we aren't already running so we don't get backed up
    if not redis_connection.get(FETCH_ALL_RUNS_LOCK):
        with redis_connection.lock(FETCH_ALL_RUNS_LOCK, timeout=600):
            logger.info("Starting flow run fetch for all orgs...")

            for org in Org.objects.filter(is_active=True).prefetch_related("polls"):
                run_org_task(org, fetch_org_runs)
    else:
        logger.warn("Skipping run fetch as it is already running")
Beispiel #4
0
def sync_all_fields():
    """Remove any contact fields that have been removed remotely."""
    logger.info("Syncing DataFields for active orgs.")
    for org in Org.objects.filter(is_active=True):
        run_org_task(org, sync_org_fields)
    logger.info("Finished syncing DataFields for active orgs.")