in correlations.js [406:540]
in_channel_target: getChannelPercentage(
channel_target,
elem.item
),
in_channel: getChannelPercentage(channel, elem.item),
};
});
});
}
function getChannelsProperties(product) {
return loadChannelsDifferencesData(product)
.then(() =>
["release", "beta", "nightly"].map((channel) =>
channelsData[channel].map(
(longitudinalElem) => Object.keys(longitudinalElem.item)[0]
)
)
)
.then((all_props_per_channel) =>
[].concat.apply([], all_props_per_channel)
)
.then((all_props) => new Set(all_props))
.then((props) => Array.from(props));
}
function getChannelsValues(product, property) {
return loadChannelsDifferencesData(product)
.then(() =>
["release", "beta", "nightly"].map((channel) =>
channelsData[channel]
.filter(
(longitudinalElem) =>
Object.keys(longitudinalElem.item).indexOf(property) != -1
)
.map((longitudinalElem) => longitudinalElem.item[property])
)
)
.then((all_values_per_channel) =>
[].concat.apply([], all_values_per_channel)
)
.then((all_values) => new Set(all_values))
.then((values) => Array.from(values));
}
function getChannelsPercentage(product, channel, property, value) {
return loadChannelsDifferencesData(product).then(() =>
channelsData[channel].find(
(longitudinalElem) =>
Object.keys(longitudinalElem.item).indexOf(property) != -1 &&
longitudinalElem.item[property] == value
)
);
}
function text(textElem, signature, channel, product, show_ci = false) {
loadCorrelationData(signature, channel, product).then((data) => {
textElem.textContent = "";
if (!(product in data)) {
textElem.textContent =
"No correlation data was generated for the '" +
product +
"' product.";
return;
}
if (
!(signature in data[product][channel]["signatures"]) ||
!data[product][channel]["signatures"][signature]["results"]
) {
textElem.textContent =
'No correlation data was generated for the signature "' +
signature +
'" on the ' +
channel +
" channel, for the '" +
product +
"' product.";
return;
}
let correlationData =
data[product][channel]["signatures"][signature]["results"];
let total_reference = data[product][channel].total;
let total_group = data[product][channel]["signatures"][signature].total;
textElem.textContent = sortCorrelationData(
correlationData,
total_reference,
total_group
).reduce((prev, cur) => {
let support_group = toPercentage(cur.count_group / total_group);
let support_reference = toPercentage(
cur.count_reference / total_reference
);
let support_diff = toPercentage(
Math.abs(
cur.count_group / total_group -
cur.count_reference / total_reference
)
);
let ci = confidenceInterval(
cur.count_group,
total_group,
cur.count_reference,
total_reference
);
let support_diff_incertezza = toPercentage(
Math.abs(
Math.abs(ci[0]) -
Math.abs(
cur.count_group / total_group -
cur.count_reference / total_reference
)
)
);
let res =
prev +
"(" +
support_group +
"% in signature vs " +
support_reference +
"% overall, difference " +
support_diff +
"±" +
support_diff_incertezza +
"%) " +
itemToLabel(cur.item);
if (cur.prior) {