Ejemplo n.º 1
0
def index_data(alias, index):
    logger.info('Reindexing {0}'.format(index))

    try:
        get_modules()[alias].reindex(index)
    except Exception as exc:
        index_data.retry(args=(alias, index), exc=exc, max_retries=3)
        raise
Ejemplo n.º 2
0
def get_daterange_or_404(start, end):
    """Parse and validate a pair of YYYYMMDD date strings."""
    dates = DateForm(data={'start': start, 'end': end})
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        raise http.Http404

    return (dates.cleaned_data['start'], dates.cleaned_data['end'])
Ejemplo n.º 3
0
def index_data(alias, index):
    logger.info('Reindexing {0}'.format(index))

    try:
        get_modules()[alias].reindex(index)
    except Exception as exc:
        index_data.retry(
            args=(alias, index), exc=exc, max_retries=3)
        raise
Ejemplo n.º 4
0
def get_daterange_or_404(start, end):
    """Parse and validate a pair of YYYYMMDD date strings."""
    dates = DateForm(data={'start': start, 'end': end})
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        raise http.Http404

    return (
        dates.cleaned_data['start'],
        dates.cleaned_data['end']
    )
Ejemplo n.º 5
0
def get_report_view(request):
    """Parse and validate a pair of YYYMMDD date strings."""
    dates = DateForm(data=request.GET)
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        return {}

    if dates.cleaned_data.get('start') and dates.cleaned_data.get('end'):
        return {
            'range': 'custom',
            'start': dates.cleaned_data['start'].strftime('%Y%m%d'),
            'end': dates.cleaned_data['end'].strftime('%Y%m%d'),
        }

    elif dates.cleaned_data.get('last'):
        return {
            'range': dates.cleaned_data['last'],
            'last': str(dates.cleaned_data['last']) + ' days'
        }

    logger.info('Missing "start and end" or "last"')
    return {}
Ejemplo n.º 6
0
def get_report_view(request):
    """Parse and validate a pair of YYYMMDD date strings."""
    dates = DateForm(data=request.GET)
    if not dates.is_valid():
        logger.info('Dates parsed were not valid.')
        return {}

    if dates.cleaned_data.get('start') and dates.cleaned_data.get('end'):
        return {
            'range': 'custom',
            'start': dates.cleaned_data['start'].strftime('%Y%m%d'),
            'end': dates.cleaned_data['end'].strftime('%Y%m%d'),
        }

    elif dates.cleaned_data.get('last'):
        return {
            'range': dates.cleaned_data['last'],
            'last': str(dates.cleaned_data['last']) + ' days'
        }

    logger.info('Missing "start and end" or "last"')
    return {}
Ejemplo n.º 7
0
def gather_index_data_tasks(alias, index):
    """
    Return a group of indexing tasks for that index.
    """
    logger.info('Returning reindexing group for {0}'.format(index))
    return get_modules()[alias].reindex_tasks_group(index)
Ejemplo n.º 8
0
def gather_index_data_tasks(alias, index):
    """
    Return a group of indexing tasks for that index.
    """
    logger.info('Returning reindexing group for {0}'.format(index))
    return get_indexer(alias).reindex_tasks_group(index)
Ejemplo n.º 9
0
def flag_database(new_index, old_index, alias):
    """Flags the database to indicate that the reindexing has started."""
    logger.info('Flagging the database to start the reindexation')
    flag_reindexing_amo(new_index=new_index, old_index=old_index, alias=alias)
Ejemplo n.º 10
0
def unflag_database():
    """Unflag the database to indicate that the reindexing is over."""
    logger.info('Unflagging the database')
    unflag_reindexing_amo()
Ejemplo n.º 11
0
def update_aliases(actions):
    logger.info('Rebuilding aliases with actions: %s' % actions)
    ES.indices.update_aliases({'actions': actions})
Ejemplo n.º 12
0
def create_new_index(alias, new_index):
    logger.info(
        'Create the index {0}, for alias: {1}'.format(new_index, alias))
    get_indexer(alias).create_new_index(new_index)
Ejemplo n.º 13
0
def create_new_index(alias, new_index):
    logger.info(f'Create the index {new_index}, for alias: {alias}')
    get_indexer(alias).create_new_index(new_index)
Ejemplo n.º 14
0
def delete_indexes(indexes):
    indices = ','.join(indexes)
    logger.info('Removing indices %r' % indices)
    ES.indices.delete(indices, ignore=[404, 500])
Ejemplo n.º 15
0
def delete_indexes(indexes):
    indices = ','.join(indexes)
    logger.info('Removing indices %r' % indices)
    ES.indices.delete(indices, ignore=[404, 500])
Ejemplo n.º 16
0
def unflag_database():
    """Unflag the database to indicate that the reindexing is over."""
    logger.info('Unflagging the database')
    unflag_reindexing_amo()
Ejemplo n.º 17
0
def flag_database(new_index, old_index, alias):
    """Flags the database to indicate that the reindexing has started."""
    logger.info('Flagging the database to start the reindexation')
    flag_reindexing_amo(new_index=new_index, old_index=old_index, alias=alias)
Ejemplo n.º 18
0
def update_aliases(actions):
    logger.info('Rebuilding aliases with actions: %s' % actions)
    ES.indices.update_aliases({'actions': actions})
Ejemplo n.º 19
0
def create_new_index(alias, new_index):
    logger.info(
        'Create the index {0}, for alias: {1}'.format(new_index, alias))
    get_modules()[alias].create_new_index(new_index)