Created
September 21, 2016 15:11
-
-
Save bhardin/b4fa7fcfa5f6ae1dc3d24f8eb99730a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from myapp.celery_config import celery_app | |
from myapp.corporations.models import Corporation | |
logger = logging.getLogger() | |
@celery_app.task( | |
name='analytics.update_corporation_data', | |
queue='whenever', | |
ignore_result=True, | |
) | |
def update_corporation_data(corp_pk): | |
corporation = Corporation.objects.get(pk=corp_pk) | |
logger.info(u'Updating stored data for %s (pk: %s)' % ( | |
corporation, corporation.pk)) | |
corporation.update_data() | |
@celery_app.task( | |
name='analytics.update_all_corporations', | |
queue='whenever', | |
ignore_result=True | |
) | |
def update_all_corporations(): | |
for corporation in Corporation.objects.all(): | |
update_corporation_data.apply_async(args=(corporation.pk,)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment