1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
function build_summary(div_id, json_file) {
d3.json(json_file, function(error, targets) {
if (error) {
return console.warn(error)
}
// Describe the table
let columns = [
{
title: "Target",
},
{
title: "All",
html: function(target) {
if ("all" in target) {
return "<a href=\"" + target.target + ".log\">" + target.all + "</a>"
} else {
return ""
}
},
}
]
// Add a column for each OS
let platforms = targets.reduce(
function(r, target) {
if (target.platform) {
return r.add(target.platform)
} else {
return r
}
},
new Set())
for (let platform of platforms) {
columns.push({
title: platform,
html: function(target) {
// code below merges platform results
if (platform in target) {
return "<a href=\"" + target.target + "-" + platform + ".log\">" + target[platform] + "</a>"
} else {
return ""
}
},
})
}
console.log("columns", columns)
// Merge identical targets
// Build the table
let runs = targets.reduce(
function(m, target) {
let mm
if (m.has(target.target)) {
// m[target] already exists, update it
mm = m.get(target.target)
} else {
// m[target] doesn't exist, create it
mm = new Object()
mm["target"] = target.target
m.set(target.target, mm)
}
// Add the new status
if (target.platform) {
mm[target.platform] = target.status
} else {
mm["all"] = target.status
}
return m
},
new Map()
)
console.log("runs", runs)
lsw_table({
id: div_id,
data: runs.values(),
columns: columns,
})
})
}
|