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
1
Merge Requests
1
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
Boxiang Sun
erp5
Commits
6defa865
Commit
6defa865
authored
Sep 13, 2019
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement faster getCreationDate response on large workflow lists
parent
16f740ac
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
14 deletions
+61
-14
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+17
-13
product/ERP5Type/patches/WorkflowTool.py
product/ERP5Type/patches/WorkflowTool.py
+44
-1
No files found.
product/ERP5Type/Base.py
View file @
6defa865
...
...
@@ -3184,19 +3184,23 @@ class Base( CopyContainer,
Returns the creation date of the document based on workflow information
"""
# Check if edit_workflow defined
portal_workflow
=
self
.
getPortalObject
().
portal_workflow
wf
=
portal_workflow
.
getWorkflowById
(
'edit_workflow'
)
wf_list
=
portal_workflow
.
getWorkflowsFor
(
self
)
if
wf
is
not
None
:
wf_list
=
[
wf
]
+
wf_list
for
wf
in
wf_list
:
try
:
history
=
wf
.
getInfoFor
(
self
,
'history'
,
None
)
except
KeyError
:
history
=
None
if
history
is
not
None
and
len
(
history
):
# Then get the first line of edit_workflow
return
history
[
0
].
get
(
'time'
,
None
)
history_list
=
aq_base
(
self
).
workflow_history
except
AttributeError
:
pass
else
:
candidate
=
None
for
wf_id
,
history
in
history_list
.
iteritems
():
try
:
if
wf_id
==
"edit_workflow"
:
return
history
[
0
][
'time'
]
elif
candidate
is
None
:
candidate
=
history
[
0
][
'time'
]
except
(
IndexError
,
KeyError
,
TypeError
):
pass
if
candidate
is
not
None
:
return
candate
if
getattr
(
aq_base
(
self
),
'CreationDate'
,
None
)
is
not
None
:
return
asDate
(
self
.
CreationDate
())
return
None
# JPS-XXX - try to find a way to return a creation date instead of None
...
...
product/ERP5Type/patches/WorkflowTool.py
View file @
6defa865
...
...
@@ -722,7 +722,7 @@ def WorkflowTool_refreshWorklistCache(self):
security
.
declareProtected
(
Permissions
.
ManagePortal
,
'refreshWorklistCache'
)
WorkflowTool
.
refreshWorklistCache
=
WorkflowTool_refreshWorklistCache
class
WorkflowHistoryList
(
Persistent
):
class
WorkflowHistory
Bucket
List
(
Persistent
):
_bucket_size
=
16
def
__init__
(
self
,
iterable
=
None
,
prev
=
None
):
...
...
@@ -748,6 +748,13 @@ class WorkflowHistoryList(Persistent):
if
index
<
0
:
# XXX this implementation is not so good, but rarely used.
index
+=
len
(
self
)
elif
index
<=
self
.
_bucket_size
:
if
getattr
(
self
,
'_first'
,
None
):
# Speed up access to the first elements
return
self
.
_first
.
_slots
[
index
]
if
self
.
_prev
is
not
None
and
getattr
(
self
,
"_init_first"
,
None
):
self
.
_init_first
()
return
self
.
_first
.
_slots
[
index
]
iterator
=
self
.
__iter__
()
for
i
in
xrange
(
index
):
iterator
.
next
()
...
...
@@ -806,6 +813,42 @@ class WorkflowHistoryList(Persistent):
self
.
_prev
=
self
.
__class__
(
self
.
_slots
,
prev
=
self
.
_prev
)
self
.
_slots
=
[
value
]
class
WorkflowHistoryList
(
WorkflowHistoryBucketList
):
def
__init__
(
self
,
iterable
=
None
,
prev
=
None
):
WorkflowHistoryBucketList
.
__init__
(
self
,
iterable
,
prev
)
self
.
_first
=
None
def
_init_first
(
self
):
if
getattr
(
self
,
'_first'
,
None
)
is
None
:
# Handle migration of old workflow history
bucket
=
self
.
_prev
while
bucket
.
_prev
is
not
None
:
bucket
=
bucket
.
_prev
self
.
_first
=
bucket
self
.
_p_changed
=
1
def
append
(
self
,
value
):
if
len
(
self
.
_slots
)
<
self
.
_bucket_size
:
self
.
_slots
.
append
(
value
)
self
.
_p_changed
=
1
else
:
self
.
_prev
=
WorkflowHistoryBucketList
(
self
.
_slots
,
prev
=
self
.
_prev
)
self
.
_slots
=
[
value
]
self
.
_init_first
()
def
__setstate__
(
self
,
state
):
if
len
(
state
)
==
2
:
self
.
_prev
,
self
.
_slots
=
state
self
.
_first
=
None
else
:
self
.
_prev
,
self
.
_slots
,
self
.
_first
=
state
def
__getstate__
(
self
):
return
(
self
.
_prev
,
self
.
_slots
,
getattr
(
self
,
"_first"
,
None
))
def
WorkflowTool_setStatusOf
(
self
,
wf_id
,
ob
,
status
):
""" Append an entry to the workflow history.
...
...
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