Commit 0ee7f875 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: Remove the custom catalog method to avoid index creation date

Now creation date is fast, there is no need for this custom code anymore.
parent 7dc2661a
<catalog_method>
<item key="sql_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method>
REPLACE INTO
catalog
(`uid`, `security_uid`, `group_security_uid`, `shadow_security_uid`, `computer_security_uid`,`user_security_uid`, `subscription_security_uid`, `organisation_security_uid`,`project_security_uid`,
`owner`, `viewable_owner`, `path`, `relative_url`, `parent_uid`, `id`, `description`, `title`, `meta_type`,
`portal_type`, `opportunity_state`, `corporate_registration_code`, `ean13_code`, `validation_state`, `simulation_state`,
`causality_state`, `invoice_state`, `payment_state`, `event_state`, `immobilisation_state`, `reference`, `grouping_reference`,
`source_reference`, `destination_reference`, `string_index`, `int_index`, `float_index`, `has_cell_content`, `modification_date`)
VALUES
<dtml-in prefix="loop" expr="_.range(_.len(uid))">
(
<dtml-sqlvar expr="uid[loop_item]" type="int">,
<dtml-sqlvar expr="security_uid[loop_item]" type="int">,
<dtml-sqlvar expr="group_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="shadow_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="computer_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="user_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="subscription_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="organisation_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="project_security_uid[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getOwnerInfo[loop_item]['id']" type="string">,
<dtml-sqlvar expr="(getViewPermissionOwner[loop_item] is not None) and getViewPermissionOwner[loop_item] or ''" type="string" optional>,
<dtml-sqlvar expr="getPath[loop_item]" type="string">,
<dtml-sqlvar expr="getRelativeUrl[loop_item]" type="string">,
<dtml-sqlvar expr="getParentUid[loop_item]" type="int">,
<dtml-sqlvar expr="id[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getDescription[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getTitle[loop_item]" type="string" optional>,
<dtml-sqlvar expr="meta_type[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getPortalType[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getOpportunityState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getCorporateRegistrationCode[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getEan13Code[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getValidationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getSimulationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getCausalityState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getInvoiceState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getPaymentState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getEventState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getImmobilisationState[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getGroupingReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getSourceReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getDestinationReference[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getStringIndex[loop_item]" type="string" optional>,
<dtml-sqlvar expr="getIntIndex[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getFloatIndex[loop_item]" type="float" optional>,
<dtml-sqlvar expr="hasCellContent[loop_item]" type="int" optional>,
<dtml-sqlvar expr="getModificationDate[loop_item]" type="datetime" optional>
)
<dtml-if sequence-end><dtml-else>,</dtml-if>
</dtml-in>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="SQL Method" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>allow_simple_one_argument_traversal</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>arguments_src</string> </key>
<value> <string>uid\n
security_uid\n
group_security_uid\n
shadow_security_uid\n
computer_security_uid\n
subscription_security_uid\n
user_security_uid\n
organisation_security_uid\n
project_security_uid\n
getOwnerInfo\n
getViewPermissionOwner\n
getPath\n
getRelativeUrl\n
getParentUid\n
id\n
getDescription\n
getTitle\n
meta_type\n
getPortalType\n
getOpportunityState\n
getCorporateRegistrationCode\n
getEan13Code\n
getSimulationState\n
getCausalityState\n
getInvoiceState\n
getValidationState\n
getPaymentState\n
getEventState\n
getImmobilisationState\n
getReference\n
getGroupingReference\n
getSourceReference\n
getDestinationReference\n
getStringIndex\n
getIntIndex\n
getFloatIndex\n
hasCellContent\n
getModificationDate</string> </value>
</item>
<item>
<key> <string>cache_time_</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>class_file_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>class_name_</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_hook</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>connection_id</string> </key>
<value> <string>erp5_sql_connection</string> </value>
</item>
<item>
<key> <string>expression</string> </key>
<value> <string>python: context.getPortalType() in (\'Software Instance\', \'Slave Instance\', \'Computer\', \'Computer Partition\', \'Sale Order\')</string> </value>
</item>
<item>
<key> <string>expression_cache_key</string> </key>
<value>
<tuple>
<string>portal_type</string>
</tuple>
</value>
</item>
<item>
<key> <string>filtered</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>z_catalog_no_workflow_date_object_list</string> </value>
</item>
<item>
<key> <string>max_cache_</string> </key>
<value> <int>100</int> </value>
</item>
<item>
<key> <string>max_rows_</string> </key>
<value> <int>1000</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>SQL Method</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>z_catalog_no_workflow_date_object_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -81,7 +81,9 @@ getModificationDate</string> </value>
</item>
<item>
<key> <string>expression</string> </key>
<value> <string>python: context.getPortalType() not in (\'Software Instance\', \'Slave Instance\', \'Computer\', \'Computer Partition\', \'Sale Order\') </string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>expression_cache_key</string> </key>
......@@ -91,7 +93,7 @@ getModificationDate</string> </value>
</item>
<item>
<key> <string>filtered</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
......
"""
When the workflow history is too big the response time
of getCreationDate is too high.
Use Cache to void recalculate it.
"""
from Products.ERP5Type.Cache import CachingMethod
portal = context.getPortalObject()
def getCachedCreationDate(relative_url):
return portal.restrictedTraverse(relative_url).getCreationDate()
return CachingMethod(getCachedCreationDate,
id="Base_getCachedCreationDate_",
cache_factory="dms_cache_factory")(context.getRelativeUrl())
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getCachedCreationDate</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getSlapToolMemcacheDict</string> </value>
<value> <string>Base_getSlapToolMemcachedDict</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -2,7 +2,7 @@ from DateTime import DateTime
import json
partition = context
memcached_dict = context.Base_getSlapToolMemcacheDict()
memcached_dict = context.Base_getSlapToolMemcachedDict()
result = ""
date = None
......
......@@ -22,7 +22,7 @@ comment = ''
if can_allocate:
# Check if computer has error reported
memcached_dict = context.Base_getSlapToolMemcacheDict()
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[computer.getReference()]
except KeyError:
......
from DateTime import DateTime
import json
memcached_dict = context.Base_getSlapToolMemcacheDict()
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[context.getReference()]
except KeyError:
......
......@@ -5,7 +5,7 @@ has_partition = context.getAggregate(portal_type="Computer Partition")
result = 'Unable to calculate the status...'
if has_partition:
try:
memcached_dict = context.Base_getSlapToolMemcacheDict()
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[context.getReference()]
except KeyError:
......
......@@ -14,7 +14,7 @@ software_installation = portal.portal_catalog.getResultValue(
if not software_installation or software_installation.getSlapState() == "destroy_requested":
return '<span" style="%s" title="Information not available"></a>' % error_style
memcached_dict = context.Base_getSlapToolMemcacheDict()
memcached_dict = context.Base_getSlapToolMemcachedDict()
try:
d = memcached_dict[software_installation.getReference()]
except KeyError:
......
......@@ -8,7 +8,6 @@ erp5_mysql_innodb/z0_uncatalog_software_instance
erp5_mysql_innodb/z_catalog_computer_partition_list
erp5_mysql_innodb/z_catalog_email_list
erp5_mysql_innodb/z_catalog_item_list
erp5_mysql_innodb/z_catalog_no_workflow_date_object_list
erp5_mysql_innodb/z_catalog_object_list
erp5_mysql_innodb/z_catalog_slapos_item_list
erp5_mysql_innodb/z_catalog_software_instance_list
......
......@@ -14,7 +14,7 @@ if portal.ERP5Site_isSupportRequestCreationClosed():
date_check_limit = addToDate(DateTime(), to_add={'hour': -1})
if (date_check_limit - hosting_subscription.Base_getCachedCreationDate()) < 0:
if (date_check_limit - hosting_subscription.getCreationDate()) < 0:
# Too early to check
return
......@@ -29,7 +29,7 @@ failing_instance = None
# Check if at least one software Instance is Allocated
for instance in software_instance_list:
if (date_check_limit - instance.Base_getCachedCreationDate()) < 0:
if (date_check_limit - instance.getCreationDate()) < 0:
continue
if instance.getSlapState() != "start_requested":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment