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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
7a857653
Commit
7a857653
authored
Mar 17, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFActivity py3
parent
2cf489d2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
product/CMFActivity/Activity/SQLBase.py
product/CMFActivity/Activity/SQLBase.py
+13
-13
product/CMFActivity/Activity/SQLDict.py
product/CMFActivity/Activity/SQLDict.py
+2
-2
No files found.
product/CMFActivity/Activity/SQLBase.py
View file @
7a857653
...
@@ -141,10 +141,10 @@ def sqltest_dict():
...
@@ -141,10 +141,10 @@ def sqltest_dict():
if
value
is
None
:
# XXX: see comment in SQLBase._getMessageList
if
value
is
None
:
# XXX: see comment in SQLBase._getMessageList
return
column
+
b" IS NULL"
return
column
+
b" IS NULL"
for
x
in
value
:
for
x
in
value
:
return
b"%s IN (%s)"
%
(
column
,
str2bytes
(
', '
.
join
(
map
(
return
str2bytes
(
"%s IN (%s)"
%
(
column
,
', '
.
join
(
map
(
str
if
isinstance
(
x
,
_SQLTEST_NO_QUOTE_TYPE_SET
)
else
str
if
isinstance
(
x
,
_SQLTEST_NO_QUOTE_TYPE_SET
)
else
render_datetime
if
isinstance
(
x
,
DateTime
)
else
render_datetime
if
isinstance
(
x
,
DateTime
)
else
render_string
,
value
))))
lambda
v
:
bytes2str
(
render_string
(
v
))
,
value
))))
return
b"0"
return
b"0"
sqltest_dict
[
name
]
=
render
sqltest_dict
[
name
]
=
render
_
(
'active_process_uid'
)
_
(
'active_process_uid'
)
...
@@ -246,7 +246,7 @@ def getNow(db):
...
@@ -246,7 +246,7 @@ def getNow(db):
Note that this value is not cached, and is not transactionnal on MySQL
Note that this value is not cached, and is not transactionnal on MySQL
side.
side.
"""
"""
return
db
.
query
(
"SELECT UTC_TIMESTAMP(6)"
,
0
)[
1
][
0
][
0
]
return
db
.
query
(
b
"SELECT UTC_TIMESTAMP(6)"
,
0
)[
1
][
0
][
0
]
class
SQLBase
(
Queue
):
class
SQLBase
(
Queue
):
"""
"""
...
@@ -284,7 +284,7 @@ CREATE TABLE %s (
...
@@ -284,7 +284,7 @@ CREATE TABLE %s (
db
=
activity_tool
.
getSQLConnection
()
db
=
activity_tool
.
getSQLConnection
()
create
=
self
.
createTableSQL
()
create
=
self
.
createTableSQL
()
if
clear
:
if
clear
:
db
.
query
(
"DROP TABLE IF EXISTS "
+
self
.
sql_table
)
db
.
query
(
str2bytes
(
"DROP TABLE IF EXISTS "
+
self
.
sql_table
)
)
db
.
query
(
create
)
db
.
query
(
create
)
else
:
else
:
src
=
db
.
upgradeSchema
(
create
,
create_if_not_exists
=
1
,
src
=
db
.
upgradeSchema
(
create
,
create_if_not_exists
=
1
,
...
@@ -789,7 +789,7 @@ CREATE TABLE %s (
...
@@ -789,7 +789,7 @@ CREATE TABLE %s (
b" %s%s"
b" %s%s"
b" ORDER BY priority, date"
b" ORDER BY priority, date"
b" LIMIT %i"
b" LIMIT %i"
b")"
%
args
).
format
(
*
a
,
*
k
))
b")"
%
args
).
format
(
*
a
,
*
*
k
))
result
=
Results
(
query
(
result
=
Results
(
query
(
b"SELECT *"
b"SELECT *"
b" FROM (%s) AS t"
b" FROM (%s) AS t"
...
@@ -833,8 +833,8 @@ CREATE TABLE %s (
...
@@ -833,8 +833,8 @@ CREATE TABLE %s (
"""
"""
Put messages back in given processing_node.
Put messages back in given processing_node.
"""
"""
db
.
query
(
"UPDATE %s SET processing_node=%s WHERE uid IN (%s)
\
0
COMMIT"
%
(
db
.
query
(
(
"UPDATE %s SET processing_node=%s WHERE uid IN (%s)
\
0
COMMIT"
%
(
self
.
sql_table
,
state
,
','
.
join
(
map
(
str
,
uid_list
))))
self
.
sql_table
,
state
,
','
.
join
(
map
(
str
,
uid_list
))))
.
encode
())
def
getProcessableMessageLoader
(
self
,
db
,
processing_node
):
def
getProcessableMessageLoader
(
self
,
db
,
processing_node
):
# do not merge anything
# do not merge anything
...
@@ -1041,16 +1041,16 @@ CREATE TABLE %s (
...
@@ -1041,16 +1041,16 @@ CREATE TABLE %s (
return
not
message_list
return
not
message_list
def
deleteMessageList
(
self
,
db
,
uid_list
):
def
deleteMessageList
(
self
,
db
,
uid_list
):
db
.
query
(
"DELETE FROM %s WHERE uid IN (%s)"
%
(
db
.
query
(
str2bytes
(
"DELETE FROM %s WHERE uid IN (%s)"
%
(
self
.
sql_table
,
','
.
join
(
map
(
str
,
uid_list
))))
self
.
sql_table
,
','
.
join
(
map
(
str
,
uid_list
))))
)
def
reactivateMessageList
(
self
,
db
,
uid_list
,
delay
,
retry
):
def
reactivateMessageList
(
self
,
db
,
uid_list
,
delay
,
retry
):
db
.
query
(
"UPDATE %s SET"
db
.
query
(
str2bytes
(
"UPDATE %s SET"
" date = DATE_ADD(UTC_TIMESTAMP(6), INTERVAL %s SECOND)"
" date = DATE_ADD(UTC_TIMESTAMP(6), INTERVAL %s SECOND)"
"%s WHERE uid IN (%s)"
%
(
"%s WHERE uid IN (%s)"
%
(
self
.
sql_table
,
delay
,
self
.
sql_table
,
delay
,
", retry = retry + 1"
if
retry
else
""
,
", retry = retry + 1"
if
retry
else
""
,
","
.
join
(
map
(
str
,
uid_list
))))
","
.
join
(
map
(
str
,
uid_list
))))
)
def
finalizeMessageExecution
(
self
,
activity_tool
,
message_list
,
def
finalizeMessageExecution
(
self
,
activity_tool
,
message_list
,
uid_to_duplicate_uid_list_dict
=
None
):
uid_to_duplicate_uid_list_dict
=
None
):
...
@@ -1207,8 +1207,8 @@ CREATE TABLE %s (
...
@@ -1207,8 +1207,8 @@ CREATE TABLE %s (
To simulate time shift, we simply substract delay from
To simulate time shift, we simply substract delay from
all dates in message(_queue) table
all dates in message(_queue) table
"""
"""
activity_tool
.
getSQLConnection
().
query
(
"UPDATE %s SET"
activity_tool
.
getSQLConnection
().
query
(
(
"UPDATE %s SET"
" date = DATE_SUB(date, INTERVAL %s SECOND)"
" date = DATE_SUB(date, INTERVAL %s SECOND)"
%
(
self
.
sql_table
,
delay
)
%
(
self
.
sql_table
,
delay
)
+
(
''
if
processing_node
is
None
else
+
(
''
if
processing_node
is
None
else
"WHERE processing_node=%s"
%
processing_node
))
"WHERE processing_node=%s"
%
processing_node
))
.
encode
())
product/CMFActivity/Activity/SQLDict.py
View file @
7a857653
...
@@ -142,10 +142,10 @@ class SQLDict(SQLBase):
...
@@ -142,10 +142,10 @@ class SQLDict(SQLBase):
if reserve_uid_list:
if reserve_uid_list:
self.assignMessageList(db, processing_node, reserve_uid_list)
self.assignMessageList(db, processing_node, reserve_uid_list)
else:
else:
db.query("COMMIT") # XXX: useful ?
db.query(
b
"COMMIT") # XXX: useful ?
except:
except:
self._log(WARNING, '
Failed
to
reserve
duplicates
')
self._log(WARNING, '
Failed
to
reserve
duplicates
')
db.query("ROLLBACK")
db.query(
b
"ROLLBACK")
raise
raise
if uid_list:
if uid_list:
self._log(TRACE, '
Reserved
duplicate
messages
:
%
r' % uid_list)
self._log(TRACE, '
Reserved
duplicate
messages
:
%
r' % uid_list)
...
...
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