mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 23:02:19 +00:00
Added Reddit recurring tasks to update the details
This commit is contained in:
@@ -46,3 +46,38 @@ def process_validations():
|
|||||||
except LoginError, exc:
|
except LoginError, exc:
|
||||||
logger.error("Error logging into Reddit")
|
logger.error("Error logging into Reddit")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@task(ignore_result=True)
|
||||||
|
def update_account(username):
|
||||||
|
|
||||||
|
logger = process_validations.get_logger()
|
||||||
|
|
||||||
|
try:
|
||||||
|
acc = RedditAccount.objects.get(pk=username)
|
||||||
|
except RedditAccount.DoesNotExist:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
acc.api_update
|
||||||
|
acc.save()
|
||||||
|
|
||||||
|
|
||||||
|
@task(ignore_result=True, expires=120)
|
||||||
|
def queue_account_updates(update_delay=604800, batch_size=50):
|
||||||
|
"""
|
||||||
|
Updates all Reddit accounts in the system
|
||||||
|
"""
|
||||||
|
|
||||||
|
log = queue_account_updates.get_logger()
|
||||||
|
# Update all the eve accounts and related corps
|
||||||
|
delta = timedelta(seconds=update_delay)
|
||||||
|
log.info("Updating Accounts older than %s" % (datetime.now() - delta))
|
||||||
|
accounts = RedditAccount.objects.filter(last_updated_lt=(datetime.now() - delta))
|
||||||
|
log.info("%s account(s) to update" % accounts.count())
|
||||||
|
for acc in accounts:
|
||||||
|
log.debug("Queueing Account %s for update" % acc.username)
|
||||||
|
if not acc.user:
|
||||||
|
acc.delete()
|
||||||
|
continue
|
||||||
|
update_account.delay(username=acc.pk)
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,10 @@ CELERYBEAT_SCHEDULE = {
|
|||||||
"task": "hr.tasks.blacklist_check",
|
"task": "hr.tasks.blacklist_check",
|
||||||
"schedule": timedelta(days=1),
|
"schedule": timedelta(days=1),
|
||||||
},
|
},
|
||||||
|
"reddit-update": {
|
||||||
|
"task": "reddit.tasks.queue_account_updates",
|
||||||
|
"schedule": timedelta(minutes=15),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CELERY_SEND_TASK_ERROR_EMAILS = True
|
CELERY_SEND_TASK_ERROR_EMAILS = True
|
||||||
@@ -204,6 +208,7 @@ CELERY_RESULT_BACKEND = "amqp"
|
|||||||
CELERY_DISABLE_RATE_LIMITS = True
|
CELERY_DISABLE_RATE_LIMITS = True
|
||||||
CELERYD_PREFETCH_MULTIPLIER = 128
|
CELERYD_PREFETCH_MULTIPLIER = 128
|
||||||
CELERY_ALWAYS_EAGER = DEBUG
|
CELERY_ALWAYS_EAGER = DEBUG
|
||||||
|
CELERY_EAGER_PROPAGATES_EXCEPTIONS = DEBUG
|
||||||
|
|
||||||
# Load the Celery tasks
|
# Load the Celery tasks
|
||||||
djcelery.setup_loader()
|
djcelery.setup_loader()
|
||||||
|
|||||||
Reference in New Issue
Block a user