Synchronisation is performed in the background by the Celery Beat, every 10 minutes. It has a time limit of 9 minutes to prevent multiple refresh tasks from running at the same time. Synchronisation is also possible with the `manage.py badges sync` CLI command, which can sync either a single user or all users.
21 lines
645 B
Python
21 lines
645 B
Python
"""Badge HTML synchronisation.
|
|
|
|
Note that this module can only be imported when an application context is
|
|
active. Best to late-import this in the functions where it's needed.
|
|
"""
|
|
import datetime
|
|
import logging
|
|
|
|
from pillar import current_app, badge_sync
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
@current_app.celery.task(ignore_result=True)
|
|
def sync_badges_for_users(timelimit_seconds: int):
|
|
"""Synchronises Blender ID badges for the most-urgent users."""
|
|
|
|
timelimit = datetime.timedelta(seconds=timelimit_seconds)
|
|
log.info('Refreshing badges, timelimit is %s (H:MM:SS)', timelimit)
|
|
badge_sync.refresh_all_badges(timelimit=timelimit)
|