Commit a27ecf00 authored by Boxiang Sun's avatar Boxiang Sun Committed by Tristan Cavelier

erp5_officejs_support_request_ui: Improve support request statistic computing speed.

parent 5f8457eb
...@@ -154,11 +154,12 @@ ...@@ -154,11 +154,12 @@
data: [ data: [
{ {
value_dict: { value_dict: {
0: ["< 2", "2-7", "7-30"], 0: ["< 2", "2-7", "7-30", "> 30"],
1: [ 1: [
sp_data.le2.validated, sp_data.le2.validated,
sp_data['2to7'].validated, sp_data['2to7'].validated,
sp_data['7to30'].validated sp_data['7to30'].validated,
sp_data.gt30.validated
] ]
}, },
colors: ['#d48265'], colors: ['#d48265'],
...@@ -167,11 +168,12 @@ ...@@ -167,11 +168,12 @@
}, },
{ {
value_dict: { value_dict: {
0: ["< 2", "2-7", "7-30"], 0: ["< 2", "2-7", "7-30", "> 30"],
1: [ 1: [
sp_data.le2.submitted, sp_data.le2.submitted,
sp_data['2to7'].submitted, sp_data['2to7'].submitted,
sp_data['7to30'].submitted sp_data['7to30'].submitted,
sp_data.gt30.submitted
] ]
}, },
colors: ['#61a0a8'], colors: ['#61a0a8'],
...@@ -180,11 +182,12 @@ ...@@ -180,11 +182,12 @@
}, },
{ {
value_dict: { value_dict: {
0: ["< 2", "2-7", "7-30"], 0: ["< 2", "2-7", "7-30", "> 30"],
1: [ 1: [
sp_data.le2.suspended, sp_data.le2.suspended,
sp_data['2to7'].suspended, sp_data['2to7'].suspended,
sp_data['7to30'].suspended sp_data['7to30'].suspended,
sp_data.gt30.suspended
] ]
}, },
colors: ['#c23531'], colors: ['#c23531'],
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.25742.4974.61781</string> </value> <value> <string>962.25743.31377.26094</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1506605728.66</float> <float>1506606769.12</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -14,15 +14,15 @@ date_30_midnight = DateTime(str(date_30.year()) + "-" + str(date_30.month()) + " ...@@ -14,15 +14,15 @@ date_30_midnight = DateTime(str(date_30.year()) + "-" + str(date_30.month()) + "
support_request_list = portal.portal_catalog( support_request_list = portal.portal_catalog(
portal_type="Support Request", portal_type="Support Request",
modification_date={'query':date_30_midnight,'range':'nlt'} select_list=['simulation_state', 'modification_date']
) )
count_by_state = {} count_by_state = {}
count_by_date = {"le2": {}, "2to7": {}, "7to30": {}} count_by_date = {"le2": {}, "2to7": {}, "7to30": {}, "gt30": {}}
for sr in support_request_list: for sr in support_request_list:
sr_date = sr.getModificationDate() sr_date = sr.getProperty("modification_date")
sr_state = sr.getSimulationState() sr_state = sr.getProperty("simulation_state")
if sr_state not in count_by_state: if sr_state not in count_by_state:
count_by_state[sr_state] = 0 count_by_state[sr_state] = 0
...@@ -35,8 +35,13 @@ for sr in support_request_list: ...@@ -35,8 +35,13 @@ for sr in support_request_list:
count_by_date["le2"][sr_state] = count_by_date["le2"][sr_state] + 1 count_by_date["le2"][sr_state] = count_by_date["le2"][sr_state] + 1
elif sr_date >= date_7_midnight: elif sr_date >= date_7_midnight:
count_by_date["2to7"][sr_state] = count_by_date["2to7"][sr_state] + 1 count_by_date["2to7"][sr_state] = count_by_date["2to7"][sr_state] + 1
else: elif sr_date >= date_30_midnight:
count_by_date["7to30"][sr_state] = count_by_date["7to30"][sr_state] + 1 count_by_date["7to30"][sr_state] = count_by_date["7to30"][sr_state] + 1
else:
count_by_date["gt30"][sr_state] = count_by_date["gt30"][sr_state] + 1
if sr_date < date_30_midnight:
continue
count_by_state[sr_state] = count_by_state[sr_state] + 1 count_by_state[sr_state] = count_by_state[sr_state] + 1
......
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