aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-07-14 19:47:52 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-07-14 19:47:52 +0300
commitf0392649a986c2fbbb979686c5d4d001a7328d69 (patch)
treefd80fd7bc5e40354d0140e92215fe254abbaced1
parent05d143f874fc0f78ed5325cee38fd2b9d64861ce (diff)
downloadlinaro-android-frontend-f0392649a986c2fbbb979686c5d4d001a7328d69.tar.gz
Switch order of jobs vs tables processing when categorizing jobs.
Instead of processing job list thru all tabs' filters, which always requires N*M steps, process each job thru each tab's filter, until match found. This on average requies M*N/2 steps, and there's also opportunity to optimize this further by putting frequently-matching patterns at the beginning of sequence (not pursued so far). Async processing introduced in previous change is also preserved. Subjectively, this change leads to great improvement, page loads in a second or so. Change-Id: If3103ca03f71c0398419ba0d3b4a5af7807b3aa2
-rw-r--r--static/index.js238
1 files changed, 136 insertions, 102 deletions
diff --git a/static/index.js b/static/index.js
index d9840c1..c70d7fa 100644
--- a/static/index.js
+++ b/static/index.js
@@ -251,11 +251,6 @@ YUI(Yconfig).use(
newData: function (records) {
var recordset = new Y.Recordset({records: records});
recordset.plug(Y.Plugin.RecordsetFilter);
- var filter = this.get('filter');
- if (filter) {
- recordset = recordset.filter.filter(filter);
- recordset.plug(Y.Plugin.RecordsetFilter);
- }
this.get("host").set("recordset", recordset);
this.unfiltered_data = recordset;
this.status = "Any";
@@ -293,7 +288,7 @@ YUI(Yconfig).use(
}
- function makeDT(id, filter) {
+ function makeDT(id) {
var columns = [
{label:"Status", key: 'status'},
{label:"Name", key: 'name'},
@@ -344,7 +339,7 @@ YUI(Yconfig).use(
);
dt.plug(MyDataTableDataFilter, {
- filter: filter
+ filter: null
});
return dt;
}
@@ -352,167 +347,175 @@ YUI(Yconfig).use(
var userRegexp = (
globalConfig.userName ? new RegExp('^~' + globalConfig.userName + '/') : null);
- var tables = [
- makeDT(
+ // This is array and not map proper to have stable processing order and be able to
+ // put frequently-matching patterns towards the beginning
+ var job_patterns = [
+ [
"#engineering-daily-build-table",
function (item) {
var group = 'linaro-android';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0 && item.getValue('name').search(/toolchain/) == -1 &&
- item.getValue('name').search(/galaxynexus-linaro-gcctrunk/) == -1 &&
- item.getValue('name').search(/panda-jb-gcctrunk-tilt-tracking-blob/) == -1;
+ return item.name.search(pattern) == 0 && item.name.search(/toolchain/) == -1 &&
+ item.name.search(/galaxynexus-linaro-gcctrunk/) == -1 &&
+ item.name.search(/panda-jb-gcctrunk-tilt-tracking-blob/) == -1;
- }),
- makeDT(
+ }],
+ [
"#engineering-release-build-table",
function (item) {
var group = 'linaro-android';
var pattern = new RegExp("^~" + group + "\/.*?(?:release).*$");
- return item.getValue('name').search(pattern) == 0 && item.getValue('name').search(/toolchain/) == -1;
- }),
- makeDT(
+ return item.name.search(pattern) == 0 && item.name.search(/toolchain/) == -1;
+ }],
+ [
"#engineering-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-restricted\//) == 0 && item.getValue('name').search(/toolchain/) == -1;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-restricted\//) == 0 && item.name.search(/toolchain/) == -1;
+ }],
+ [
"#member-ti-build-table",
function (item) {
var group = 'linaro-android-member-ti';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0;
+ }],
+ [
"#member-ti-release-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-ti\/.*?(?:release).*$/) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-ti\/.*?(?:release).*$/) == 0;
+ }],
+ [
"#member-ti-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-ti-restricted\//) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-ti-restricted\//) == 0;
+ }],
+ [
"#member-samsung-build-table",
function (item) {
var group = 'linaro-android-member-samsung';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0;
+ }],
+ [
"#member-samsung-release-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-samsung\/.*?(?:release).*$/) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-samsung\/.*?(?:release).*$/) == 0;
+ }],
+ [
"#member-samsung-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-samsung-restricted\//) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-samsung-restricted\//) == 0;
+ }],
+ [
"#member-arm-build-table",
function (item) {
var group = 'linaro-android-member-arm';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0;
+ }],
+ [
"#member-arm-release-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-arm\/.*?(?:release).*$/) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-arm\/.*?(?:release).*$/) == 0;
+ }],
+ [
"#member-arm-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-arm-restricted\//) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-arm-restricted\//) == 0;
+ }],
+ [
"#member-ste-build-table",
function (item) {
var group = 'linaro-android-member-ste';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0;
+ }],
+ [
"#member-ste-release-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-ste\/.*?(?:release).*$/) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-ste\/.*?(?:release).*$/) == 0;
+ }],
+ [
"#member-ste-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-ste-restricted\//) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-ste-restricted\//) == 0;
+ }],
+ [
"#member-hisilicon-build-table",
function (item) {
var group = 'linaro-android-member-hisilicon';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0;
+ }],
+ [
"#member-hisilicon-release-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-hisilicon\/.*?(?:release).*$/) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-hisilicon\/.*?(?:release).*$/) == 0;
+ }],
+ [
"#member-hisilicon-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-hisilicon-restricted\//) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-hisilicon-restricted\//) == 0;
+ }],
+ [
"#member-fujitsu-build-table",
function (item) {
var group = 'linaro-android-member-fujitsu';
var pattern = new RegExp("^~" + group + "\/(?!.*release).*$");
- return item.getValue('name').search(pattern) == 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0;
+ }],
+ [
"#member-fujitsu-release-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-fujitsu\/.*?(?:release).*$/) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-fujitsu\/.*?(?:release).*$/) == 0;
+ }],
+ [
"#member-fujitsu-restricted-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-member-fujitsu-restricted\//) == 0;
- }),
- makeDT(
+ return item.name.search(/^~linaro-android-member-fujitsu-restricted\//) == 0;
+ }],
+ [
"#user-build-table",
(userRegexp ?
- function (item) { return item.getValue('name').search(userRegexp) == 0; } :
- function (item) { return false; })
- ),
- makeDT(
+ function (item) { return item.name.search(userRegexp) == 0; } :
+ function (item) { return false; }
+ )],
+ [
"#toolchain-build-table",
function (item) {
var group = 'linaro-android';
var pattern = new RegExp("^~" + group + "\/(?!.*201?\.??).*$");
- return item.getValue('name').search(pattern) == 0 && item.getValue('name').search(/toolchain/) > 0 && item.getValue('name').search(/aarch64/) == -1 ||
- item.getValue('name').search(/galaxynexus-linaro-gcctrunk/) >= 0 ||
- item.getValue('name').search(/panda-jb-gcctrunk-tilt-tracking-blob/) >= 0;
- }),
- makeDT(
+ return item.name.search(pattern) == 0 && item.name.search(/toolchain/) > 0 && item.name.search(/aarch64/) == -1 ||
+ item.name.search(/galaxynexus-linaro-gcctrunk/) >= 0 ||
+ item.name.search(/panda-jb-gcctrunk-tilt-tracking-blob/) >= 0;
+ }],
+ [
"#toolchain-release-build-table",
function (item) {
var group = 'linaro-android';
var pattern = new RegExp("^~" + group + "\/.*?(?:201?\.??).*$");
- return item.getValue('name').search(pattern) == 0 && item.getValue('name').search(/toolchain/) > 0 && item.getValue('name').search(/aarch64/) == -1;
- }),
- makeDT(
+ return item.name.search(pattern) == 0 && item.name.search(/toolchain/) > 0 && item.name.search(/aarch64/) == -1;
+ }],
+ [
"#toolchain-restricted-build-table",
function (item) {
var group = 'linaro-android-restricted';
var pattern = new RegExp("^~" + group + "\/.*?(?:aarch64).*$");
- return item.getValue('name').search(pattern) == 0 && item.getValue('name').search(/toolchain/) > 0;
- }),
- makeDT("#archive-all-build-table",
- function (item) { return item.getValue('name').search(/^~linaro-android-archive\//) == 0; }),
- makeDT("#archive-restricted-build-table",
- function (item) { return item.getValue('name').search(/^~linaro-android-archive-restricted\//) == 0; }),
- makeDT("#community-build-table",
+ return item.name.search(pattern) == 0 && item.name.search(/toolchain/) > 0;
+ }],
+ [
+ "#archive-all-build-table",
+ function (item) { return item.name.search(/^~linaro-android-archive\//) == 0; }
+ ],
+ [
+ "#archive-restricted-build-table",
+ function (item) { return item.name.search(/^~linaro-android-archive-restricted\//) == 0; }
+ ],
+ [
+ "#community-build-table",
function (item) {
- return item.getValue('name').search(/^~linaro-android-community\//) == 0;})
+ return item.name.search(/^~linaro-android-community\//) == 0;}
+ ]
];
@@ -550,8 +553,11 @@ YUI(Yconfig).use(
return results;
}
+ var jobs_classif = {};
+ for (var i = 0; i < job_patterns.length; i++) {
+ jobs_classif[job_patterns[i][0]] = [];
+ }
console.log("Fetching jobs");
- console.log(tables);
Y.io(
globalConfig.jenkinsURL + "/api/json?tree=" + treeExp,
{
@@ -562,15 +568,43 @@ YUI(Yconfig).use(
var jobs = extractJobsFromResponse(response.responseText);
console.log("Parsed jobs");
var q = new Y.AsyncQueue();
- for (var i = 0; i < tables.length; i++) {
- // Replaced synchronous table filling with async below
- //tables[i].datafilter.newData(jobs);
- q.add((function(i) {
- return function() { tables[i].datafilter.newData(jobs); }
- })(i));
+ for (var chunk = 0; chunk < jobs.length; chunk += 40) {
+ var categorize_jobs = function(start) {
+ return function() {
+ console.log("Processing chunk ", start);
+ var end = start + 40;
+ if (end > jobs.length) end = jobs.length;
+ for (var i = start; i < end; i++) {
+ var found = false;
+ for (var j = 0; j < job_patterns.length; j++) {
+ if (job_patterns[j][1](jobs[i])) {
+ jobs_classif[job_patterns[j][0]].push(jobs[i]);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ // This is expected, for example, other users'
+ // jobs are not shown in any tab
+ //console.log("Uncategorized job: ", jobs[i]);
+ }
+ }
+ }
+ }
+ q.add(categorize_jobs(chunk));
+ }
+
+ var populate_tables = function() {
+ console.log("classified: ", jobs_classif);
+ for (var name in jobs_classif) {
+ var dt = makeDT(name);
+ dt.datafilter.newData(jobs_classif[name]);
+ }
+ console.log("Done loading");
}
+ q.add(populate_tables);
q.run();
- console.log("Populated job tables");
+ console.log("Started async processing");
}
}
}