63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from datetime import timedelta
|
|
|
|
from kombu import Exchange, Queue
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from mayan.celery import app
|
|
from common import MayanAppConfig, menu_object, menu_secondary, menu_tools
|
|
|
|
from .classes import Statistic, StatisticNamespace
|
|
from .links import (
|
|
link_execute, link_namespace_details, link_namespace_list,
|
|
link_statistics
|
|
)
|
|
from .literals import STATISTICS_REFRESH_INTERVAL
|
|
from .tasks import task_check_statistics # NOQA - Force registration of task
|
|
|
|
|
|
class StatisticsApp(MayanAppConfig):
|
|
name = 'statistics'
|
|
verbose_name = _('Statistics')
|
|
|
|
def ready(self):
|
|
super(StatisticsApp, self).ready()
|
|
|
|
app.conf.CELERYBEAT_SCHEDULE.update(
|
|
{
|
|
'statistics.task_check_statistics': {
|
|
'task': 'statistics.tasks.task_check_statistics',
|
|
'schedule': timedelta(seconds=STATISTICS_REFRESH_INTERVAL),
|
|
},
|
|
}
|
|
)
|
|
|
|
app.conf.CELERY_QUEUES.extend(
|
|
(
|
|
Queue(
|
|
'statistics', Exchange('statistics'),
|
|
routing_key='statistics', delivery_mode=1
|
|
),
|
|
)
|
|
)
|
|
|
|
app.conf.CELERY_ROUTES.update(
|
|
{
|
|
'statistics.tasks.task_check_statistics': {
|
|
'queue': 'statistics'
|
|
},
|
|
}
|
|
)
|
|
|
|
menu_object.bind_links(links=(link_execute,), sources=(Statistic,))
|
|
menu_object.bind_links(
|
|
links=(link_namespace_details,), sources=(StatisticNamespace,)
|
|
)
|
|
menu_secondary.bind_links(
|
|
links=(link_namespace_list,),
|
|
sources=(StatisticNamespace, 'statistics:namespace_list')
|
|
)
|
|
menu_tools.bind_links(links=(link_statistics,))
|