Commit bf9a98ab authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_crm: remove unused script

parent d241a081
from DateTime import DateTime
from Products.ERP5Type.Document import newTempDocument
portal = context.getPortalObject()
# Hardcode the Date Range here
today = DateTime()
date_set = set(["%s/%02d" % ((today-x).year(), (today-x).month()) for x in range(0,370, 27)])
def getSupportRequestList(creation_date, resource_uid=None):
return portal.portal_catalog(
portal_type="Support Request",
default_resource_uid=resource_uid,
creation_date=creation_date)
def countSupportRequest(creation_date, resource_uid=None):
return len(getSupportRequestList(creation_date, resource_uid))
def countEvent(creation_date, resource_uid=None):
sr_uid_list = [sr.uid for sr in getSupportRequestList(creation_date, resource_uid)]
if not sr_uid_list:
return 0
return portal.portal_catalog.countResults(
default_follow_up_uid=[sr.uid for sr in getSupportRequestList(creation_date, resource_uid)],
creation_date=creation_date)[0][0]
monitor_resource_uid = context.service_module.slapos_crm_monitoring.getUid()
stats_list = []
creation_date_list = list(date_set)
creation_date_list.sort()
for creation_date in creation_date_list:
line = newTempDocument(context, '%s' % creation_date.replace("/", "_"), **{
"uid": "%s_%s" % (context.getUid(), len(stats_list)),
"title": creation_date,
"event_user_amount": countEvent(creation_date, resource_uid='NOT %s' % monitor_resource_uid),
"user_amount": countSupportRequest(creation_date, resource_uid='NOT %s' % monitor_resource_uid),
"monitor_amount": countSupportRequest(creation_date, resource_uid=monitor_resource_uid),
"event_monitor_amount": countEvent(creation_date, resource_uid=monitor_resource_uid)})
stats_list.append(line)
return stats_list
<?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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupportRequestModule_getTicketActivityReportList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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