def run(): if 'name_finnish' not in columns(): print 'ok' setup_mapping() else: print 'skippint' assert 'name_finnish' in columns()
def reindex_apps_task(index=None, aliased=True): """Apps do get indexed by `reindex_addons`, but run this for apps only.""" from . import tasks search.setup_mapping(index, aliased) ids = (Addon.objects.values_list('id', flat=True) .filter(type=amo.ADDON_WEBAPP, status__in=amo.VALID_STATUSES, disabled_by_user=False)) return group([tasks.index_addons.si(chunk, index=index) for chunk in chunked(sorted(list(ids)), 150)])
def reindex_apps(): """Apps do get indexed by `reindex_addons`, but run this for apps only.""" from . import tasks search.setup_mapping() ids = (Addon.objects.values_list('id', flat=True) .filter(type=amo.ADDON_WEBAPP, status__in=amo.VALID_STATUSES, disabled_by_user=False)) ts = [tasks.index_addons.subtask(args=[chunk]) for chunk in chunked(sorted(list(ids)), 150)] TaskSet(ts).apply_async()
def reindex_addons(): from . import tasks # Make sure our mapping is up to date. search.setup_mapping() ids = Addon.objects.values_list("id", flat=True).filter( _current_version__isnull=False, status__in=amo.VALID_STATUSES, disabled_by_user=False ) ts = [tasks.index_addons.subtask(args=[chunk]) for chunk in chunked(sorted(list(ids)), 150)] TaskSet(ts).apply_async()
def reindex_addons(): from . import tasks # Make sure our mapping is up to date. search.setup_mapping() ids = (Addon.objects.values_list('id', flat=True) .filter(_current_version__isnull=False, status__in=amo.VALID_STATUSES, disabled_by_user=False)) ts = [tasks.index_addons.subtask(args=[chunk]) for chunk in chunked(sorted(list(ids)), 150)] TaskSet(ts).apply_async()
def reindex_apps_task(index=None, aliased=True): """Apps do get indexed by `reindex_addons`, but run this for apps only.""" from . import tasks search.setup_mapping(index, aliased) ids = (Addon.objects.values_list('id', flat=True).filter( type=amo.ADDON_WEBAPP, status__in=amo.VALID_STATUSES, disabled_by_user=False)) return group([ tasks.index_addons.si(chunk, index=index) for chunk in chunked(sorted(list(ids)), 150) ])
def reindex_addons(index=None, aliased=True, addon_type=None): from . import tasks # Make sure our mapping is up to date. search.setup_mapping(index, aliased) ids = (Addon.objects.values_list('id', flat=True) .filter(_current_version__isnull=False, status__in=amo.VALID_STATUSES, disabled_by_user=False)) if addon_type: ids = ids.filter(type=addon_type) ts = [tasks.index_addons.subtask(args=[chunk], kwargs=dict(index=index)) for chunk in chunked(sorted(list(ids)), 150)] TaskSet(ts).apply_async()
def reindex_apps(): """Apps do get indexed by `reindex_addons`, but run this for apps only.""" from . import tasks search.setup_mapping() ids = (Addon.objects.values_list('id', flat=True).filter( type=amo.ADDON_WEBAPP, status__in=amo.VALID_STATUSES, disabled_by_user=False)) ts = [ tasks.index_addons.subtask(args=[chunk]) for chunk in chunked(sorted(list(ids)), 150) ] TaskSet(ts).apply_async()
def reindex_addons_task(index=None, aliased=True, addon_type=None): from . import tasks # Make sure our mapping is up to date. search.setup_mapping(index, aliased) ids = (Addon.objects.values_list('id', flat=True) .filter(_current_version__isnull=False, status__in=amo.VALID_STATUSES, disabled_by_user=False)) if addon_type: ids = ids.filter(type=addon_type) p = group([tasks.index_addons.si(chunk, index=index) for chunk in chunked(sorted(list(ids)), 150)]) return p
def reindex_addons_task(index=None, aliased=True, addon_type=None): from . import tasks # Make sure our mapping is up to date. search.setup_mapping(index, aliased) ids = (Addon.objects.values_list('id', flat=True).filter( _current_version__isnull=False, status__in=amo.VALID_STATUSES, disabled_by_user=False)) if addon_type: ids = ids.filter(type=addon_type) p = group([ tasks.index_addons.si(chunk, index=index) for chunk in chunked(sorted(list(ids)), 150) ]) return p
def elastic(request): INDEX = settings.ES_INDEXES['default'] es = elasticutils.get_es() mappings = { 'addons': reindex_addons, 'apps': reindex_apps, 'collections': reindex_collections, 'compat': compatibility_report, 'users': reindex_users, 'stats_latest': index_latest_stats, 'mkt_stats': index_mkt_stats, 'mkt_stats_latest': index_latest_mkt_stats } if request.method == 'POST': if request.POST.get('recreate'): es.delete_index_if_exists(INDEX) # We must set up the mappings before we create the index again. setup_mapping() setup_indexes() if setup_mkt_indexes: setup_mkt_indexes() create_es_index_if_missing(INDEX) messages.info(request, 'Deleting %s index.' % INDEX) if request.POST.get('reindex') in mappings: name = request.POST['reindex'] # Reindex. if mappings.get(name): mappings[name]() messages.info(request, 'Reindexing %s.' % name) return redirect('zadmin.elastic') indexes = set(settings.ES_INDEXES.values()) es_mappings = es.get_mapping(None, indexes) ctx = { 'index': INDEX, 'nodes': es.cluster_nodes(), 'health': es.cluster_health(), 'state': es.cluster_state(), 'mappings': [(index, es_mappings.get(index, {})) for index in indexes], 'choices': mappings, } return jingo.render(request, 'zadmin/elastic.html', ctx)
def elastic(request): INDEX = settings.ES_INDEXES["default"] es = elasticutils.get_es() mappings = { "addons": reindex_addons, "apps": reindex_apps, "collections": reindex_collections, "compat": compatibility_report, "users": reindex_users, "stats_latest": index_latest_stats, "mkt_stats": index_mkt_stats, "mkt_stats_latest": index_latest_mkt_stats, } if request.method == "POST": if request.POST.get("recreate"): es.delete_index_if_exists(INDEX) # We must set up the mappings before we create the index again. setup_mapping() setup_indexes() if setup_mkt_indexes: setup_mkt_indexes() create_es_index_if_missing(INDEX) messages.info(request, "Deleting %s index." % INDEX) if request.POST.get("reindex") in mappings: name = request.POST["reindex"] # Reindex. if mappings.get(name): mappings[name]() messages.info(request, "Reindexing %s." % name) return redirect("zadmin.elastic") indexes = set(settings.ES_INDEXES.values()) es_mappings = es.get_mapping(None, indexes) ctx = { "index": INDEX, "nodes": es.cluster_nodes(), "health": es.cluster_health(), "state": es.cluster_state(), "mappings": [(index, es_mappings.get(index, {})) for index in indexes], "choices": mappings, } return jingo.render(request, "zadmin/elastic.html", ctx)
def elastic(request): INDEX = settings.ES_INDEXES['default'] es = elasticutils.get_es() mappings = {'addons': reindex_addons, 'apps': reindex_apps, 'collections': reindex_collections, 'compat': compatibility_report, 'users': reindex_users, 'stats_latest': index_latest_stats, 'mkt_stats': index_mkt_stats, 'mkt_stats_latest': index_latest_mkt_stats} if request.method == 'POST': if request.POST.get('recreate'): es.delete_index_if_exists(INDEX) # We must set up the mappings before we create the index again. setup_mapping() setup_indexes() if setup_mkt_indexes: setup_mkt_indexes() create_es_index_if_missing(INDEX) messages.info(request, 'Deleting %s index.' % INDEX) if request.POST.get('reindex') in mappings: name = request.POST['reindex'] # Reindex. if mappings.get(name): mappings[name]() messages.info(request, 'Reindexing %s.' % name) return redirect('zadmin.elastic') indexes = set(settings.ES_INDEXES.values()) es_mappings = es.get_mapping(None, indexes) ctx = { 'index': INDEX, 'nodes': es.cluster_nodes(), 'health': es.cluster_health(), 'state': es.cluster_state(), 'mappings': [(index, es_mappings.get(index, {})) for index in indexes], 'choices': mappings, } return jingo.render(request, 'zadmin/elastic.html', ctx)