Beispiel #1
0
def index_theme_user_counts(ids, index=None, **kw):
    index = index or search.get_alias()

    es = amo.search.get_es()
    qs = ThemeUserCount.objects.filter(id__in=ids)

    if qs:
        log.info('Indexing %s theme user counts for %s.'
                 % (qs.count(), qs[0].date))
    data = []
    try:
        for user_count in qs:
            data.append(search.extract_theme_user_count(user_count))
        bulk_index(es, data, index=index,
                   doc_type=ThemeUserCount.get_mapping_type(), refresh=True)
    except Exception, exc:
        index_theme_user_counts.retry(args=[ids], exc=exc, **kw)
        raise
Beispiel #2
0
def index_theme_user_counts(ids, index=None, **kw):
    index = index or search.get_alias()

    es = amo.search.get_es()
    qs = ThemeUserCount.objects.filter(id__in=ids)

    if qs:
        log.info('Indexing %s theme user counts for %s.'
                 % (qs.count(), qs[0].date))
    data = []
    try:
        for user_count in qs:
            data.append(search.extract_theme_user_count(user_count))
        bulk_index(es, data, index=index,
                   doc_type=ThemeUserCount.get_mapping_type(), refresh=True)
    except Exception, exc:
        index_theme_user_counts.retry(args=[ids], exc=exc, **kw)
        raise
Beispiel #3
0
def index_theme_user_counts(ids, **kw):
    index = kw.pop('index', None)
    indices = get_indices(index)

    es = amo.search.get_es()
    qs = ThemeUserCount.objects.filter(id__in=ids)

    if qs:
        log.info('Indexing %s theme user counts for %s.'
                 % (qs.count(), qs[0].date))
    try:
        for user_count in qs:
            key = '%s-%s' % (user_count.addon_id, user_count.date)
            data = search.extract_theme_user_count(user_count)
            for index in indices:
                ThemeUserCount.index(data, bulk=True, id=key, index=index)
            es.flush_bulk(forced=True)
    except Exception, exc:
        index_theme_user_counts.retry(args=[ids], exc=exc)
        raise
Beispiel #4
0
def index_theme_user_counts(ids, **kw):
    index = kw.pop('index', None)
    indices = get_indices(index)

    es = amo.search.get_es()
    qs = ThemeUserCount.objects.filter(id__in=ids)

    if qs:
        log.info('Indexing %s theme user counts for %s.' %
                 (qs.count(), qs[0].date))
    try:
        for user_count in qs:
            key = '%s-%s' % (user_count.addon_id, user_count.date)
            data = search.extract_theme_user_count(user_count)
            for index in indices:
                ThemeUserCount.index(data, bulk=True, id=key, index=index)
            es.flush_bulk(forced=True)
    except Exception, exc:
        index_theme_user_counts.retry(args=[ids], exc=exc)
        raise