Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
erp5
Commits
ac62192a
Commit
ac62192a
authored
Sep 13, 2013
by
Tatuya Kamada
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Invenotory: Change to use inventory cache even if we do not specify the date."
Needs more tests. This reverts commit
74db4d39
.
parent
74db4d39
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
55 deletions
+10
-55
bt5/erp5_stock_cache/SkinTemplateItem/portal_skins/erp5_stock_cache/Resource_zGetInventoryCacheResult.xml
...ns/erp5_stock_cache/Resource_zGetInventoryCacheResult.xml
+1
-3
bt5/erp5_stock_cache/bt/revision
bt5/erp5_stock_cache/bt/revision
+1
-1
product/ERP5/Tool/SimulationTool.py
product/ERP5/Tool/SimulationTool.py
+8
-12
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+0
-39
No files found.
bt5/erp5_stock_cache/SkinTemplateItem/portal_skins/erp5_stock_cache/Resource_zGetInventoryCacheResult.xml
View file @
ac62192a
...
@@ -60,10 +60,8 @@ FROM \n
...
@@ -60,10 +60,8 @@ FROM \n
inventory_cache \n
inventory_cache \n
WHERE \n
WHERE \n
inventory_cache.query=<dtml-sqlvar query type="string">
\n
inventory_cache.query=<dtml-sqlvar query type="string">
\n
<dtml-if
date
>
\n
AND \n
AND \n
inventory_cache.date
<
=
<dtml-sqlvar
date
type=
"datetime"
>
\n
inventory_cache.date
<
=
<dtml-sqlvar
date
type=
"datetime"
>
\n
</dtml-if>
\n
ORDER BY \n
ORDER BY \n
date DESC
date DESC
...
...
bt5/erp5_stock_cache/bt/revision
View file @
ac62192a
14
13
\ No newline at end of file
\ No newline at end of file
product/ERP5/Tool/SimulationTool.py
View file @
ac62192a
...
@@ -1303,6 +1303,7 @@ class SimulationTool(BaseTool):
...
@@ -1303,6 +1303,7 @@ class SimulationTool(BaseTool):
# Get cached data
# Get cached data
if
getattr
(
self
,
"Resource_zGetInventoryCacheResult"
,
None
)
is
not
None
and
\
if
getattr
(
self
,
"Resource_zGetInventoryCacheResult"
,
None
)
is
not
None
and
\
optimisation__
and
(
not
kw
.
get
(
'from_date'
))
and
\
optimisation__
and
(
not
kw
.
get
(
'from_date'
))
and
\
(
bool
(
kw
.
get
(
"at_date"
))
^
bool
(
kw
.
get
(
"to_date"
)))
and
\
'transformed_resource'
not
in
kw
:
'transformed_resource'
not
in
kw
:
# Here is the different kind of date
# Here is the different kind of date
# from_date : >=
# from_date : >=
...
@@ -1313,7 +1314,7 @@ class SimulationTool(BaseTool):
...
@@ -1313,7 +1314,7 @@ class SimulationTool(BaseTool):
# of the same line
# of the same line
at_date
=
kw
.
pop
(
"at_date"
,
None
)
at_date
=
kw
.
pop
(
"at_date"
,
None
)
if
at_date
is
None
:
if
at_date
is
None
:
to_date
=
kw
.
pop
(
"to_date"
,
None
)
to_date
=
kw
.
pop
(
"to_date"
)
else
:
else
:
# add one second so that we can use to_date
# add one second so that we can use to_date
to_date
=
at_date
+
MYSQL_MIN_DATETIME_RESOLUTION
to_date
=
at_date
+
MYSQL_MIN_DATETIME_RESOLUTION
...
@@ -1401,9 +1402,10 @@ class SimulationTool(BaseTool):
...
@@ -1401,9 +1402,10 @@ class SimulationTool(BaseTool):
**
kw
)).
digest
()
**
kw
)).
digest
()
# Try to get result from cache
# Try to get result from cache
Resource_zGetInventoryCacheResult
=
self
.
Resource_zGetInventoryCacheResult
Resource_zGetInventoryCacheResult
=
self
.
Resource_zGetInventoryCacheResult
inventory_cache_kw
=
{
'query'
:
sql_text_hash
}
inventory_cache_kw
=
{
if
to_date
is
not
None
:
'query'
:
sql_text_hash
,
inventory_cache_kw
[
'date'
]
=
to_date
'date'
:
to_date
,
}
try
:
try
:
cached_sql_result
=
Resource_zGetInventoryCacheResult
(
**
inventory_cache_kw
)
cached_sql_result
=
Resource_zGetInventoryCacheResult
(
**
inventory_cache_kw
)
except
ProgrammingError
:
except
ProgrammingError
:
...
@@ -1432,10 +1434,10 @@ class SimulationTool(BaseTool):
...
@@ -1432,10 +1434,10 @@ class SimulationTool(BaseTool):
else
:
else
:
cached_result
=
[]
cached_result
=
[]
cache_lag
=
self
.
getInventoryCacheLag
()
cache_lag
=
self
.
getInventoryCacheLag
()
if
cached_sql_result
and
(
to_date
is
None
or
(
to_date
-
DateTime
(
cached_sql_result
[
0
].
date
)
<
cache_lag
))
:
if
cached_sql_result
and
to_date
-
DateTime
(
cached_sql_result
[
0
].
date
)
<
cache_lag
:
cached_date
=
DateTime
(
cached_sql_result
[
0
].
date
)
cached_date
=
DateTime
(
cached_sql_result
[
0
].
date
)
result
=
cached_result
result
=
cached_result
el
if
to_date
is
not
Non
e
:
el
s
e
:
# Cache miss, or hit with old data: store a new entry in cache.
# Cache miss, or hit with old data: store a new entry in cache.
# Don't store it at to_date, as it risks being flushed soon (ie, when
# Don't store it at to_date, as it risks being flushed soon (ie, when
# any document older than to_date gets reindexed in stock table).
# any document older than to_date gets reindexed in stock table).
...
@@ -1473,12 +1475,6 @@ class SimulationTool(BaseTool):
...
@@ -1473,12 +1475,6 @@ class SimulationTool(BaseTool):
'data'
:
result
.
_data
,
'data'
:
result
.
_data
,
}),
}),
)
)
else
:
# Cache miss and this getInventory() not specifying to_date,
# and other getInventory() have not created usable caches.
# In such case, do not create cache, do not use cache.
result
=
[]
cached_date
=
None
if
src__
:
if
src__
:
result
=
sql_source_list
result
=
sql_source_list
return
result
,
cached_date
return
result
,
cached_date
...
...
product/ERP5/tests/testInventoryAPI.py
View file @
ac62192a
...
@@ -3022,45 +3022,6 @@ class TestInventoryCacheTable(InventoryAPITestCase):
...
@@ -3022,45 +3022,6 @@ class TestInventoryCacheTable(InventoryAPITestCase):
}
}
)
)
def
test_17_GetInventoryWithoutDate
(
self
):
"""
Check getInventory without date. Without date means specifying
infinite future date. So it try to retrieve the latest cache.
Note: This behavior is compatible with the old caching implementation
that was using inventory_stock table. In other words, this brings backs
the backword compatibility in invetory caching.
"""
self
.
assertInventoryEquals
(
self
.
_fillCache
(),
inventory_kw
=
{
'node_uid'
:
self
.
node_uid
,
},
)
def
test_18_GetInventoryWithoutDate
(
self
):
"""
Check that getInventoryList without date retrives the latest caches.
"""
self
.
_fillCache
(
True
)
# Check we got all results
self
.
_checkInventoryList
(
self
.
getInventoryList
(
node_uid
=
self
.
node_uid
),
[{
'date'
:
self
.
INVENTORY_DATE_3
,
'inventory'
:
self
.
INVENTORY_QUANTITY_3
,
'node_uid'
:
self
.
node_uid
,
},
{
'date'
:
self
.
INVENTORY_DATE_2
,
'inventory'
:
self
.
INVENTORY_QUANTITY_2
,
'node_uid'
:
self
.
node_uid
,
},
{
'date'
:
self
.
INVENTORY_DATE_1
,
'inventory'
:
self
.
INVENTORY_QUANTITY_1
,
'node_uid'
:
self
.
node_uid
,
}],
)
class
BaseTestUnitConversion
(
InventoryAPITestCase
):
class
BaseTestUnitConversion
(
InventoryAPITestCase
):
QUANTITY_UNIT_DICT
=
{}
QUANTITY_UNIT_DICT
=
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment