Try this style of update tasks of the establishments
This commit is contained in:
parent
b8df164369
commit
ff006eb6fb
|
|
@ -4,11 +4,14 @@ import logging
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from celery.schedules import crontab
|
from celery.schedules import crontab
|
||||||
from celery.task import periodic_task
|
from celery.task import periodic_task
|
||||||
|
|
||||||
from django.core import management
|
from django.core import management
|
||||||
from django_elasticsearch_dsl.management.commands import search_index
|
from django_elasticsearch_dsl.management.commands import search_index
|
||||||
|
|
||||||
|
from django_elasticsearch_dsl.registries import registry
|
||||||
from establishment import models
|
from establishment import models
|
||||||
from location.models import Country
|
from location.models import Country
|
||||||
|
from search_indexes.documents.establishment import EstablishmentDocument
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -25,7 +28,18 @@ def recalculate_price_levels_by_country(country_id):
|
||||||
establishment.recalculate_price_level(low_price=country.low_price,
|
establishment.recalculate_price_level(low_price=country.low_price,
|
||||||
high_price=country.high_price)
|
high_price=country.high_price)
|
||||||
|
|
||||||
|
# @periodic_task(run_every=crontab(minute=59))
|
||||||
|
# def rebuild_establishment_indices():
|
||||||
|
# management.call_command(search_index.Command(), action='populate', models=[models.Establishment.__name__],
|
||||||
|
# force=True)
|
||||||
|
|
||||||
|
|
||||||
@periodic_task(run_every=crontab(minute=59))
|
@periodic_task(run_every=crontab(minute=59))
|
||||||
def rebuild_establishment_indices():
|
def update_establishment_indices():
|
||||||
management.call_command(search_index.Command(), action='populate', models=[models.Establishment.__name__],
|
try:
|
||||||
force=True)
|
doc = registry.get_documents([models.Establishment]).pop()
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
qs = doc().get_indexing_queryset()
|
||||||
|
doc().update(qs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user