def index_collection_counts(ids, index=None, **kw): index = index or search.get_alias() es = amo.search.get_es() qs = CollectionCount.objects.filter(collection__in=ids) if qs: log.info('Indexing %s addon collection counts: %s' % (qs.count(), qs[0].date)) data = [] try: for collection_count in qs: collection = collection_count.collection_id filters = dict(collection=collection, date=collection_count.date) data.append( search.extract_addon_collection( collection_count, AddonCollectionCount.objects.filter(**filters), CollectionStats.objects.filter(**filters))) bulk_index(es, data, index=index, doc_type=CollectionCount.get_mapping_type(), refresh=True) except Exception, exc: index_collection_counts.retry(args=[ids], exc=exc) raise
def index_download_counts(ids, index=None, **kw): index = index or search.get_alias() es = amo.search.get_es() qs = DownloadCount.objects.filter(id__in=ids) if qs: log.info('Indexing %s downloads for %s.' % (qs.count(), qs[0].date)) try: data = [] for dl in qs: data.append(search.extract_download_count(dl)) bulk_index(es, data, index=index, doc_type=DownloadCount.get_mapping_type(), refresh=True) except Exception, exc: index_download_counts.retry(args=[ids, index], exc=exc) raise
def index_update_counts(ids, index=None, **kw): index = index or search.get_alias() es = amo.search.get_es() qs = UpdateCount.objects.filter(id__in=ids) if qs: log.info('Indexing %s updates for %s.' % (qs.count(), qs[0].date)) data = [] try: for update in qs: data.append(search.extract_update_count(update)) bulk_index(es, data, index=index, doc_type=UpdateCount.get_mapping_type(), refresh=True) except Exception, exc: index_update_counts.retry(args=[ids, index], exc=exc, **kw) raise
def index_collection_counts(ids, index=None, **kw): index = index or search.get_alias() es = amo.search.get_es() qs = CollectionCount.objects.filter(collection__in=ids) if qs: log.info('Indexing %s addon collection counts: %s' % (qs.count(), qs[0].date)) data = [] try: for collection_count in qs: collection = collection_count.collection_id filters = dict(collection=collection, date=collection_count.date) data.append(search.extract_addon_collection( collection_count, AddonCollectionCount.objects.filter(**filters), CollectionStats.objects.filter(**filters))) bulk_index(es, data, index=index, doc_type=CollectionCount.get_mapping_type(), refresh=True) except Exception, exc: index_collection_counts.retry(args=[ids], exc=exc) raise