Make queue_name configurable.
This commit is contained in:
parent
615d8f58c0
commit
76feb2ce19
13
babi.py
13
babi.py
|
@ -64,8 +64,9 @@ AGGREGATE_TYPES = [
|
|||
SRC_CHARS = """ .'"()/*-+?¿!&$[]{}@#`'^:;<>=~%,|\\"""
|
||||
DST_CHARS = """__________________________________"""
|
||||
|
||||
BABI_RETENTION_DAYS = config_.getint('babi', 'retention_days', default=30)
|
||||
BABI_MAX_BD_COLUMN = config_.getint('babi', 'max_db_column', default=60)
|
||||
RETENTION_DAYS = config_.getint('babi', 'retention_days', default=30)
|
||||
MAX_BD_COLUMN = config_.getint('babi', 'max_db_column', default=60)
|
||||
QUEUE_NAME = config.get('babi', 'queue_name', default='default')
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -951,7 +952,7 @@ class Report(ModelSQL, ModelView):
|
|||
@classmethod
|
||||
@ModelView.button
|
||||
def calculate(cls, reports):
|
||||
with Transaction().set_context(queue_name='babi'):
|
||||
with Transaction().set_context(queue_name=QUEUE_NAME):
|
||||
for report in reports:
|
||||
cls.__queue__.compute(report)
|
||||
|
||||
|
@ -1135,7 +1136,7 @@ class ReportExecution(ModelSQL, ModelView):
|
|||
pool = Pool()
|
||||
Date = pool.get('ir.date')
|
||||
if date is None:
|
||||
date = Date.today() - timedelta(days=BABI_RETENTION_DAYS)
|
||||
date = Date.today() - timedelta(days=RETENTION_DAYS)
|
||||
|
||||
date = datetime.combine(date, mdatetime.time.min)
|
||||
executions = cls.search([('date', '<', date)])
|
||||
|
@ -1591,9 +1592,9 @@ class ReportExecution(ModelSQL, ModelView):
|
|||
# PSQL default column name max characters
|
||||
if ((len(internal_names) > 1)
|
||||
and (len('_'.join(internal_names)) >
|
||||
BABI_MAX_BD_COLUMN)):
|
||||
MAX_BD_COLUMN)):
|
||||
measure_len = len(measure.internal_name)
|
||||
max_len = BABI_MAX_BD_COLUMN - measure_len
|
||||
max_len = MAX_BD_COLUMN - measure_len
|
||||
combination_name = internal_names.pop(0)[:max_len]
|
||||
internal_names.insert(0, combination_name)
|
||||
to_create.append({
|
||||
|
|
3
cron.py
3
cron.py
|
@ -4,6 +4,7 @@ from trytond.model import fields, dualmethod
|
|||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.pyson import Eval
|
||||
from .babi import QUEUE_NAME
|
||||
|
||||
|
||||
class Cron(metaclass=PoolMeta):
|
||||
|
@ -64,7 +65,7 @@ class Cron(metaclass=PoolMeta):
|
|||
# babi execution require company. Run calculate when has a company
|
||||
for company in cron.companies:
|
||||
with Transaction().set_context(company=company.id,
|
||||
queue_name='babi'):
|
||||
queue_name=QUEUE_NAME):
|
||||
BabiReport.__queue__.compute(cron.babi_report)
|
||||
|
||||
table_crons = [cron for cron in crons if cron.babi_table]
|
||||
|
|
4
table.py
4
table.py
|
@ -15,7 +15,7 @@ from trytond.exceptions import UserError
|
|||
from trytond.i18n import gettext
|
||||
from trytond.pyson import Bool, Eval, PYSONDecoder
|
||||
from trytond import backend
|
||||
from .babi import TimeoutChecker, TimeoutException, FIELD_TYPES
|
||||
from .babi import TimeoutChecker, TimeoutException, FIELD_TYPES, QUEUE_NAME
|
||||
from .babi_eval import babi_eval
|
||||
|
||||
VALID_FIRST_SYMBOLS = 'abcdefghijklmnopqrstuvwxyz'
|
||||
|
@ -316,7 +316,7 @@ class Table(DeactivableMixin, ModelSQL, ModelView):
|
|||
@classmethod
|
||||
@ModelView.button
|
||||
def compute(cls, tables):
|
||||
with Transaction().set_context(queue_name='babi'):
|
||||
with Transaction().set_context(queue_name=QUEUE_NAME):
|
||||
for table in tables:
|
||||
cls.__queue__._compute(table)
|
||||
|
||||
|
|
Loading…
Reference in New Issue