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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joshua
erp5
Commits
9fe1d68d
Commit
9fe1d68d
authored
Jan 15, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFActivity: validate using single SQL request per message
parent
7e387bcb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
+30
-22
product/CMFActivity/Activity/SQLBase.py
product/CMFActivity/Activity/SQLBase.py
+8
-18
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+22
-4
No files found.
product/CMFActivity/Activity/SQLBase.py
View file @
9fe1d68d
...
@@ -254,15 +254,14 @@ class SQLBase(Queue):
...
@@ -254,15 +254,14 @@ class SQLBase(Queue):
LOG
(
'SQLBase'
,
INFO
,
'Got a lock error, retrying...'
)
LOG
(
'SQLBase'
,
INFO
,
'Got a lock error, retrying...'
)
# Validation private methods
# Validation private methods
def
getDependentMessageList
(
self
,
db
,
activate_kw
,
same_queue
):
def
getValidationSQL
(
self
,
quote
,
activate_kw
,
same_queue
):
q
=
db
.
string_literal
validate_list
=
[]
validate_list
=
[]
for
k
,
v
in
activate_kw
.
iteritems
():
for
k
,
v
in
activate_kw
.
iteritems
():
if
v
is
not
None
:
if
v
is
not
None
:
try
:
try
:
method
=
getattr
(
self
,
'_validate_'
+
k
,
None
)
method
=
getattr
(
self
,
'_validate_'
+
k
,
None
)
if
method
:
if
method
:
validate_list
.
append
(
' AND '
.
join
(
method
(
v
,
q
)))
validate_list
.
append
(
' AND '
.
join
(
method
(
v
,
q
uote
)))
except
Exception
:
except
Exception
:
LOG
(
'CMFActivity'
,
WARNING
,
'invalid %s value: %r'
%
(
k
,
v
),
LOG
(
'CMFActivity'
,
WARNING
,
'invalid %s value: %r'
%
(
k
,
v
),
error
=
True
)
error
=
True
)
...
@@ -271,21 +270,12 @@ class SQLBase(Queue):
...
@@ -271,21 +270,12 @@ class SQLBase(Queue):
same_queue
=
False
same_queue
=
False
break
break
if
validate_list
:
if
validate_list
:
message_list
=
[]
return
(
"SELECT '%s' as activity, uid, date, processing_node,"
for
line
in
Results
(
db
.
query
(
" priority, group_method_id, message FROM %s"
"SELECT * FROM %s WHERE processing_node > -10 AND (%s) LIMIT %s"
%
(
" WHERE processing_node > -10 AND (%s) LIMIT %s"
%
(
self
.
sql_table
,
' OR '
.
join
(
validate_list
),
type
(
self
).
__name__
,
self
.
sql_table
,
READ_MESSAGE_LIMIT
if
same_queue
else
1
),
0
)):
' OR '
.
join
(
validate_list
),
m
=
Message
.
load
(
line
.
message
,
READ_MESSAGE_LIMIT
if
same_queue
else
1
))
line
=
line
,
uid
=
line
.
uid
,
date
=
line
.
date
,
processing_node
=
line
.
processing_node
)
if
not
hasattr
(
m
,
'order_validation_text'
):
# BBB
m
.
order_validation_text
=
self
.
getOrderValidationText
(
m
)
message_list
.
append
(
m
)
return
message_list
return
()
def
_validate_after_method_id
(
self
,
*
args
):
def
_validate_after_method_id
(
self
,
*
args
):
return
sqltest_dict
[
'method_id'
](
*
args
),
return
sqltest_dict
[
'method_id'
](
*
args
),
...
...
product/CMFActivity/ActivityTool.py
View file @
9fe1d68d
...
@@ -57,6 +57,7 @@ from Products.ERP5Type.UnrestrictedMethod import PrivilegedUser
...
@@ -57,6 +57,7 @@ from Products.ERP5Type.UnrestrictedMethod import PrivilegedUser
from
zope.site.hooks
import
setSite
from
zope.site.hooks
import
setSite
import
transaction
import
transaction
from
App.config
import
getConfiguration
from
App.config
import
getConfiguration
from
Shared.DC.ZRDB.Results
import
Results
import
Products.Localizer.patches
import
Products.Localizer.patches
localizer_lock
=
Products
.
Localizer
.
patches
.
_requests_lock
localizer_lock
=
Products
.
Localizer
.
patches
.
_requests_lock
...
@@ -1552,10 +1553,27 @@ class ActivityTool (BaseTool):
...
@@ -1552,10 +1553,27 @@ class ActivityTool (BaseTool):
def
getDependentMessageList
(
self
,
message
,
validating_queue
=
None
):
def
getDependentMessageList
(
self
,
message
,
validating_queue
=
None
):
activity_kw
=
message
.
activity_kw
activity_kw
=
message
.
activity_kw
db
=
self
.
getSQLConnection
()
db
=
self
.
getSQLConnection
()
return
[(
activity
,
m
)
quote
=
db
.
string_literal
for
activity
in
activity_dict
.
itervalues
()
queries
=
[]
for
m
in
activity
.
getDependentMessageList
(
for
activity
in
activity_dict
.
itervalues
():
db
,
activity_kw
,
activity
is
validating_queue
)]
q
=
activity
.
getValidationSQL
(
quote
,
activity_kw
,
activity
is
validating_queue
)
if
q
:
queries
.
append
(
q
)
if
queries
:
message_list
=
[]
for
line
in
Results
(
db
.
query
(
"(%s)"
%
") UNION ALL ("
.
join
(
queries
))):
activity
=
activity_dict
[
line
.
activity
]
m
=
Message
.
load
(
line
.
message
,
line
=
line
,
uid
=
line
.
uid
,
date
=
line
.
date
,
processing_node
=
line
.
processing_node
)
if
not
hasattr
(
m
,
'order_validation_text'
):
# BBB
m
.
order_validation_text
=
activity
.
getOrderValidationText
(
m
)
message_list
.
append
((
activity
,
m
))
return
message_list
return
()
# Required for tests (time shift)
# Required for tests (time shift)
def
timeShift
(
self
,
delay
):
def
timeShift
(
self
,
delay
):
...
...
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