Commit c804124f authored by Vincent Pelletier's avatar Vincent Pelletier

Explicitely disable optimisation when from_date is provided.

  It is currently effectively (accidentaly) disabled in most cases (unless there is a full inventory exactly at given from_date), and should always be disabled.
Also, add a log when there is more than one boundary date.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24872 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 34f1aefd
...@@ -926,7 +926,7 @@ class SimulationTool(BaseTool): ...@@ -926,7 +926,7 @@ class SimulationTool(BaseTool):
getattr(self, 'Resource_zGetFullInventoryDate', None) getattr(self, 'Resource_zGetFullInventoryDate', None)
EQUAL_DATE_TABLE_ID = 'inventory_stock' EQUAL_DATE_TABLE_ID = 'inventory_stock'
GREATER_THAN_DATE_TABLE_ID = 'stock' GREATER_THAN_DATE_TABLE_ID = 'stock'
optimisation_success = optimisation__ and \ optimisation_success = optimisation__ and ('from_date' not in kw) and \
Resource_zGetFullInventoryDate is not None and \ Resource_zGetFullInventoryDate is not None and \
(GREATER_THAN_DATE_TABLE_ID == default_stock_table) (GREATER_THAN_DATE_TABLE_ID == default_stock_table)
# Generate first query parameter dict # Generate first query parameter dict
...@@ -958,8 +958,8 @@ class SimulationTool(BaseTool): ...@@ -958,8 +958,8 @@ class SimulationTool(BaseTool):
column_value_list_list = new_column_value_dict.values() column_value_list_list = new_column_value_dict.values()
date_value_list = column_value_dict.get('date', {}).get('query', []) date_value_list = column_value_dict.get('date', {}).get('query', [])
where_expression = None where_expression = None
if len(date_value_list) > 0: if len(date_value_list) == 1:
date = min(date_value_list) date = date_value_list[0]
if isinstance(date, DateTime): if isinstance(date, DateTime):
date = date.toZone('UTC').ISO() date = date.toZone('UTC').ISO()
...@@ -972,6 +972,19 @@ class SimulationTool(BaseTool): ...@@ -972,6 +972,19 @@ class SimulationTool(BaseTool):
date_query_result = date_query() date_query_result = date_query()
if date_query_result['where_expression'] not in ('',None): if date_query_result['where_expression'] not in ('',None):
where_expression = date_query_result['where_expression'] where_expression = date_query_result['where_expression']
elif len(date_value_list) > 1:
# When more than one date is provided, we must not optimise.
# Also, as we should never end up here (the only currently known
# case where there are 2 dates is when a from_date is provided
# along with either an at_date or a to_date, and we disable
# optimisation when from_date is given), emit a log.
# This can happen if there are more date parameters than mentioned
# above.
LOG('SimulationTool', 100, 'There is more than one date condition'
' so optimisation got disabled. The result of this call will be'
' correct but it requires investigation as some cases might'
' have gone unnoticed and produced wrong results.')
optimisation_success = False
return {'group_by_expression': group_by_expression, return {'group_by_expression': group_by_expression,
'column_id_list': column_id_list, 'column_id_list': column_id_list,
'column_value_list_list': column_value_list_list, 'column_value_list_list': column_value_list_list,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment