Commit 2eb94188 authored by Leo Iannacone's avatar Leo Iannacone

correctly build the all_* vectors

parent 68f098cb
...@@ -11,7 +11,7 @@ function Page_History() { ...@@ -11,7 +11,7 @@ function Page_History() {
var distributions_counter = {}; var distributions_counter = {};
var days_counter = {}; var days_counter = {};
var all_distributions = []; var all_distributions = [];
var all_days = {}; var all_days = [];
function _get_short_day(timestamp) { function _get_short_day(timestamp) {
var date = new Date(timestamp * 1000); var date = new Date(timestamp * 1000);
...@@ -52,6 +52,8 @@ function Page_History() { ...@@ -52,6 +52,8 @@ function Page_History() {
if (distributions_counter.hasOwnProperty(p.distribution)) if (distributions_counter.hasOwnProperty(p.distribution))
distributions_counter[p.distribution]++; distributions_counter[p.distribution]++;
else distributions_counter[p.distribution] = 1; else distributions_counter[p.distribution] = 1;
if (all_distributions.indexOf(p.distribution) < 0)
all_distributions.push(p.distribution);
} }
function _count_days(package_status) { function _count_days(package_status) {
...@@ -66,7 +68,8 @@ function Page_History() { ...@@ -66,7 +68,8 @@ function Page_History() {
days_counter[p.distribution] = {}; days_counter[p.distribution] = {};
days_counter[p.distribution][day] = 1; days_counter[p.distribution][day] = 1;
} }
all_days[day] = 0; if (all_days.indexOf(day) < 0)
all_days.push(day);
} }
function _sort_table() { function _sort_table() {
...@@ -107,10 +110,8 @@ function Page_History() { ...@@ -107,10 +110,8 @@ function Page_History() {
if (distributions_counter.hasOwnProperty(distro)) { if (distributions_counter.hasOwnProperty(distro)) {
distributions_data.series.push(distributions_counter[distro]); distributions_data.series.push(distributions_counter[distro]);
distributions_data.labels.push(distro + " (" + distributions_counter[distro] + ")"); distributions_data.labels.push(distro + " (" + distributions_counter[distro] + ")");
all_distributions.push(distro);
} }
} }
Chartist.Pie('#distributions-chart', distributions_data, { Chartist.Pie('#distributions-chart', distributions_data, {
donut: true, donut: true,
donutWidth: 15, donutWidth: 15,
...@@ -121,18 +122,13 @@ function Page_History() { ...@@ -121,18 +122,13 @@ function Page_History() {
// build the days Line graph // build the days Line graph
var days_data = { var days_data = {
series: [], series: [],
labels: [] labels: all_days
}; };
for (var day in all_days) {
if (all_days.hasOwnProperty(day))
days_data.labels.push(day);
}
for (var i = 0; i < all_distributions.length; i++) { for (var i = 0; i < all_distributions.length; i++) {
var info = []; var info = [];
var distro = all_distributions[i]; var distro = all_distributions[i];
for (var day in all_days) { for (var j = 0; j < all_days.length; j++) {
if (!all_days.hasOwnProperty(day)) var day = all_days[j];
continue;
if (days_counter[distro].hasOwnProperty(day)) if (days_counter[distro].hasOwnProperty(day))
info.push(days_counter[distro][day]); info.push(days_counter[distro][day]);
else else
...@@ -144,7 +140,6 @@ function Page_History() { ...@@ -144,7 +140,6 @@ function Page_History() {
} }
// init table and some objects // init table and some objects
for (var i = 0; i < dom_history.length; i++) { for (var i = 0; i < dom_history.length; i++) {
var p = dom_history[i]; var p = dom_history[i];
......
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