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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
85b7d973
Commit
85b7d973
authored
Jan 10, 2023
by
Cédric Le Ninivin
Committed by
Titouan Soulard
Apr 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_api_style: WIP Introduce latests indexation timestamp object of the hash
parent
fb2cd148
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
146 additions
and
18 deletions
+146
-18
bt5/erp5_api_style/MixinTemplateItem/portal_components/mixin.erp5.JIOAPIRevisionMixin.py
...eItem/portal_components/mixin.erp5.JIOAPIRevisionMixin.py
+22
-15
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Alarm_activateUpdateJIOAPIRevision.py
...pi_jio_sql_revision/Alarm_activateUpdateJIOAPIRevision.py
+5
-0
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zCreatejIOAPIRevisionTable.sql
..._api_jio_sql_revision/Base_zCreatejIOAPIRevisionTable.sql
+1
-0
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zGetFromIOAPIRevisionTable.sql
..._api_jio_sql_revision/Base_zGetFromIOAPIRevisionTable.sql
+1
-1
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zSelectOutdatedjIOAPIRevisionTable.sql
..._sql_revision/Base_zSelectOutdatedjIOAPIRevisionTable.sql
+1
-0
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zSelectOutdatedjIOAPIRevisionTable.xml
..._sql_revision/Base_zSelectOutdatedjIOAPIRevisionTable.xml
+71
-0
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdateTimeStampjIOAPIRevisionTable.sql
...sql_revision/Base_zUpdateTimeStampjIOAPIRevisionTable.sql
+6
-0
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdateTimeStampjIOAPIRevisionTable.xml
...sql_revision/Base_zUpdateTimeStampjIOAPIRevisionTable.xml
+35
-0
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdatejIOAPIRevisionTable.sql
..._api_jio_sql_revision/Base_zUpdatejIOAPIRevisionTable.sql
+2
-1
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdatejIOAPIRevisionTable.xml
..._api_jio_sql_revision/Base_zUpdatejIOAPIRevisionTable.xml
+2
-1
No files found.
bt5/erp5_api_style/MixinTemplateItem/portal_components/mixin.erp5.JIOAPIRevisionMixin.py
View file @
85b7d973
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
##############################################################################
##############################################################################
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
DateTime
import
DateTime
from
MySQLdb
import
ProgrammingError
from
MySQLdb
import
ProgrammingError
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
...
@@ -55,10 +56,10 @@ class JIOAPIRevisionMixin:
...
@@ -55,10 +56,10 @@ class JIOAPIRevisionMixin:
result
=
self
.
Base_zGetFromIOAPIRevisionTable
(
uid
=
self
.
getUid
())
result
=
self
.
Base_zGetFromIOAPIRevisionTable
(
uid
=
self
.
getUid
())
except
ProgrammingError
:
except
ProgrammingError
:
# jio_api_revision table is not created
# jio_api_revision table is not created
return
None
,
None
return
None
,
None
,
None
if
result
:
if
result
:
return
result
[
0
].
revision
,
result
[
0
].
hash
return
result
[
0
].
revision
,
result
[
0
].
hash
,
result
[
0
].
indexation_timestamp
return
None
,
None
return
None
,
None
,
None
def
_calculateHash
(
self
):
def
_calculateHash
(
self
):
hash_method
=
self
.
getTypeBasedMethod
(
"calculatejIOAPIRevisionHash"
)
hash_method
=
self
.
getTypeBasedMethod
(
"calculatejIOAPIRevisionHash"
)
...
@@ -71,27 +72,33 @@ class JIOAPIRevisionMixin:
...
@@ -71,27 +72,33 @@ class JIOAPIRevisionMixin:
"""
"""
Update jIO API Revision
Update jIO API Revision
"""
"""
indexation_timestamp
=
int
(
DateTime
(
self
.
getPortalObject
().
portal_catalog
(
uid
=
self
.
getUid
(),
select_list
=
(
'indexation_timestamp'
,)
)[
0
].
indexation_timestamp
))
calculated_hash
=
self
.
_calculateHash
()
calculated_hash
=
self
.
_calculateHash
()
if
not
calculated_hash
:
if
not
calculated_hash
:
self
.
_unindexJIOAPIRevision
()
self
.
_unindexJIOAPIRevision
()
return
return
stored_hash
=
None
stored_hash
=
None
_
,
stored_hash
=
self
.
_getJIOAPIRevisionTuple
()
_
,
stored_hash
,
stored_timestamp
=
self
.
_getJIOAPIRevisionTuple
()
stored_timestamp
=
int
(
DateTime
(
stored_timestamp
))
if
stored_hash
==
calculated_hash
:
if
stored_hash
==
calculated_hash
:
if
stored_timestamp
!=
indexation_timestamp
:
self
.
Base_zUpdateTimeStampjIOAPIRevisionTable
(
uid
=
self
.
getUid
(),
indexation_timestamp
=
indexation_timestamp
,
)
return
return
new_revision
=
self
.
Base_getNewjIOAPIRevision
()
new_revision
=
self
.
Base_getNewjIOAPIRevision
()
try
:
self
.
Base_zUpdatejIOAPIRevisionTable
(
self
.
Base_zUpdatejIOAPIRevisionTable
(
uid
=
self
.
getUid
(),
uid
=
self
.
getUid
(),
revision
=
new_revision
,
revision
=
new_revision
,
hash
=
calculated_hash
,
hash
=
calculated_hash
,
indexation_timestamp
=
indexation_timestamp
,
)
)
except
ProgrammingError
:
# jio_api_revision table is not created
pass
return
return
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
...
@@ -102,7 +109,7 @@ class JIOAPIRevisionMixin:
...
@@ -102,7 +109,7 @@ class JIOAPIRevisionMixin:
Fixing is not offered as it needs to be centralised to avoid missing a new revision for an object
Fixing is not offered as it needs to be centralised to avoid missing a new revision for an object
"""
"""
calculated_hash
=
self
.
_calculateHash
()
calculated_hash
=
self
.
_calculateHash
()
_
,
stored_hash
=
self
.
_getJIOAPIRevisionTuple
()
_
,
stored_hash
,
_
=
self
.
_getJIOAPIRevisionTuple
()
if
calculated_hash
!=
stored_hash
:
if
calculated_hash
!=
stored_hash
:
return
[
self
.
Base_translateString
(
return
[
self
.
Base_translateString
(
"Stored Hash ${stored_hash} difer from calculated hash ${calculated_hash}"
,
"Stored Hash ${stored_hash} difer from calculated hash ${calculated_hash}"
,
...
...
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Alarm_activateUpdateJIOAPIRevision.py
View file @
85b7d973
...
@@ -22,4 +22,9 @@ object_list = portal.portal_catalog(**kw)
...
@@ -22,4 +22,9 @@ object_list = portal.portal_catalog(**kw)
for
element
in
object_list
:
for
element
in
object_list
:
element
.
getObject
().
updateJIOAPIRevision
()
element
.
getObject
().
updateJIOAPIRevision
()
# Catch any objects that might have fell through the cracks
object_list
=
context
.
Base_zSelectOutdatedjIOAPIRevisionTable
()
for
element
in
object_list
:
portal
.
unrestrictedTraverse
(
element
.
relative_url
).
updateJIOAPIRevision
()
context
.
activate
(
after_tag
=
tag
).
getId
()
context
.
activate
(
after_tag
=
tag
).
getId
()
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zCreatejIOAPIRevisionTable.sql
View file @
85b7d973
...
@@ -2,5 +2,6 @@ CREATE TABLE `jio_api_revision` (
...
@@ -2,5 +2,6 @@ CREATE TABLE `jio_api_revision` (
`uid`
BIGINT
UNSIGNED
NOT
NULL
,
`uid`
BIGINT
UNSIGNED
NOT
NULL
,
`revision`
varchar
(
255
)
NOT
NULL
UNIQUE
,
`revision`
varchar
(
255
)
NOT
NULL
UNIQUE
,
`hash`
varchar
(
255
),
`hash`
varchar
(
255
),
`indexation_timestamp`
TIMESTAMP
(
6
),
PRIMARY
KEY
(
`uid`
)
PRIMARY
KEY
(
`uid`
)
)
ENGINE
=
InnoDB
)
ENGINE
=
InnoDB
\ No newline at end of file
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zGetFromIOAPIRevisionTable.sql
View file @
85b7d973
SELECT
SELECT
revision
,
hash
revision
,
hash
,
indexation_timestamp
FROM
FROM
jio_api_revision
jio_api_revision
WHERE
WHERE
...
...
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zSelectOutdatedjIOAPIRevisionTable.sql
0 → 100644
View file @
85b7d973
select
catalog
.
uid
,
catalog
.
relative_url
from
catalog
join
jio_api_revision
on
CAST
(
catalog
.
indexation_timestamp
AS
INT
)
!=
CAST
(
jio_api_revision
.
indexation_timestamp
AS
INT
)
AND
catalog
.
uid
=
jio_api_revision
.
uid
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zSelectOutdatedjIOAPIRevisionTable.xml
0 → 100644
View file @
85b7d973
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"SQL"
module=
"Products.ZSQLMethods.SQL"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_col
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
name
</string>
</key>
<value>
<string>
uid
</string>
</value>
</item>
<item>
<key>
<string>
null
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
type
</string>
</key>
<value>
<string>
l
</string>
</value>
</item>
<item>
<key>
<string>
width
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key>
<string>
name
</string>
</key>
<value>
<string>
relative_url
</string>
</value>
</item>
<item>
<key>
<string>
null
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
type
</string>
</key>
<value>
<string>
t
</string>
</value>
</item>
<item>
<key>
<string>
width
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
</dictionary>
</list>
</value>
</item>
<item>
<key>
<string>
arguments_src
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
connection_id
</string>
</key>
<value>
<string>
erp5_sql_connection
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_zSelectOutdatedjIOAPIRevisionTable
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdateTimeStampjIOAPIRevisionTable.sql
0 → 100644
View file @
85b7d973
UPDATE
jio_api_revision
SET
indexation_timestamp
=<
dtml
-
sqlvar
indexation_timestamp
type
=
datetime
>
WHERE
<
dtml
-
sqltest
uid
op
=
eq
type
=
int
>
\ No newline at end of file
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdateTimeStampjIOAPIRevisionTable.xml
0 → 100644
View file @
85b7d973
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"SQL"
module=
"Products.ZSQLMethods.SQL"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_col
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
arguments_src
</string>
</key>
<value>
<string>
uid\n
indexation_timestamp
</string>
</value>
</item>
<item>
<key>
<string>
connection_id
</string>
</key>
<value>
<string>
cmf_activity_sql_connection
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_zUpdateTimeStampjIOAPIRevisionTable
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdatejIOAPIRevisionTable.sql
View file @
85b7d973
...
@@ -13,6 +13,7 @@ VALUES
...
@@ -13,6 +13,7 @@ VALUES
(
(
<
dtml
-
sqlvar
expr
=
"uid"
type
=
"int"
>
,
<
dtml
-
sqlvar
expr
=
"uid"
type
=
"int"
>
,
<
dtml
-
sqlvar
expr
=
"revision"
type
=
"string"
optional
>
,
<
dtml
-
sqlvar
expr
=
"revision"
type
=
"string"
optional
>
,
<
dtml
-
sqlvar
expr
=
"hash"
type
=
"string"
optional
>
<
dtml
-
sqlvar
expr
=
"hash"
type
=
"string"
optional
>
,
<
dtml
-
sqlvar
expr
=
"indexation_timestamp"
type
=
"datetime"
optional
>
)
)
bt5/erp5_api_style/SkinTemplateItem/portal_skins/erp5_api_jio_sql_revision/Base_zUpdatejIOAPIRevisionTable.xml
View file @
85b7d973
...
@@ -10,7 +10,8 @@
...
@@ -10,7 +10,8 @@
<key>
<string>
arguments_src
</string>
</key>
<key>
<string>
arguments_src
</string>
</key>
<value>
<string>
uid\n
<value>
<string>
uid\n
revision\n
revision\n
hash
</string>
</value>
hash\n
indexation_timestamp
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
connection_id
</string>
</key>
<key>
<string>
connection_id
</string>
</key>
...
...
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