Commit f558136b authored by Roque's avatar Roque

erp5_web_project_ui: fix front page test result query

parent e084fba2
/*jslint nomen: true, indent: 2 */
/*global window, rJS, RSVP, document, SimpleQuery, ComplexQuery, Query, parseInt*/
(function (window, rJS, RSVP, document, SimpleQuery, ComplexQuery, Query, parseInt) {
/*global window, rJS, RSVP, document, SimpleQuery, ComplexQuery, Query, parseInt, jIO*/
(function (window, rJS, RSVP, document, SimpleQuery, ComplexQuery, Query, parseInt, jIO) {
"use strict";
var STATUS_OK = "green",
......@@ -421,14 +421,32 @@
return renderProjectDocumentLines(this, LIMIT_DATE);
})
.declareJob("renderTestResultInfo", function (project_list) {
var gadget = this,
i,
test_result,
query_list = [],
test_result_query,
test_state_list = ["failed", "stopped", "public_stopped"];
.declareJob("renderTestResultInfo", function () {
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({
type: "GET",
//TODO fix "erp5" part of the url
url: document.location.origin + "/erp5/ERP5Site_getProjectTestStatusData"
});
})
.push(function (result) {
var project_id,
project_test_status_dict;
project_test_status_dict = JSON.parse(result.target.response);
for (project_id in project_test_status_dict) {
if (project_test_status_dict.hasOwnProperty(project_id)) {
renderProjectLine(project_id,
"Test Result",
parseInt(project_test_status_dict[project_id].all_tests, RADIX),
parseInt(project_test_status_dict[project_id].failures, RADIX));
}
}
});
//alternative using jio queries ends up in a query per project, inefficient
//one shot query isn't possible because getting the most recent element AFTER group
//involves not supported clauses like MAX, HAVING or nested queries
/*var test_state_list = ["failed", "stopped", "public_stopped"];
.push(function () {
var promise_list = [];
for (i = 0; i < project_list.length; i += 1) {
......@@ -460,7 +478,7 @@
parseInt(test_result.value.failures, RADIX));
}
}
});
});*/
})
.declareJob("renderProjectForumLink", function () {
......@@ -508,4 +526,4 @@
return true;
});
}(window, rJS, RSVP, document, SimpleQuery, ComplexQuery, Query, parseInt));
\ No newline at end of file
}(window, rJS, RSVP, document, SimpleQuery, ComplexQuery, Query, parseInt, jIO));
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.19902.51210.17083</string> </value>
<value> <string>982.21116.37524.56610</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1583343312.59</float>
<float>1583416131.77</float>
<string>UTC</string>
</tuple>
</state>
......
import json
from DateTime import DateTime
result_dict = {}
catalog_kw = {'portal_type' : 'Test Result',
'simulation_state': ('stopped', 'failed'),
'source_project__validation_state': 'validated',
'delivery.start_date': ">= " + (DateTime()-365).strftime("%Y/%m/%d"),
}
sort_on = [('modification_date', 'descending')]
select_list = ['source_project__relative_url']
for test_result in context.portal_catalog(sort_on=sort_on, select_list=select_list, **catalog_kw):
# get the first test result (most recent) for each project
if not test_result.source_project__relative_url in result_dict:
result_dict[test_result.source_project__relative_url] = {'all_tests': test_result.all_tests,
'failures': test_result.failures}
return json.dumps(result_dict, indent=2)
<?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>ERP5Site_getProjectTestStatusData</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