mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-02-09 00:18:42 +01:00
Fixed: Add up CDNs and Frameworks over day/month/year boundaries (#74)
This commit is contained in:
parent
16f0ef8aed
commit
b94c815f32
@ -68,25 +68,42 @@ statistics._generateTable = function (data, type) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
statistics._filterAndSortData = function () {
|
statistics._filterAndSortData = function () {
|
||||||
|
let tmpCDNs, tmpFrameworks;
|
||||||
|
|
||||||
|
tmpCDNs = {};
|
||||||
|
tmpFrameworks = {};
|
||||||
|
|
||||||
// Purge
|
// Purge
|
||||||
statistics._dataSortedCDNs = {};
|
statistics._dataSortedCDNs = {};
|
||||||
statistics._dataSortedFrameworks = {};
|
statistics._dataSortedFrameworks = {};
|
||||||
|
|
||||||
statistics._dateRange.forEach(function (entry) {
|
statistics._dateRange.forEach(function (entry) {
|
||||||
if (entry in statistics._data) {
|
if (entry in statistics._data) {
|
||||||
statistics._dataSortedCDNs = Object.assign(statistics._dataSortedCDNs, statistics._data[entry]['cdns']);
|
statistics._mergeObjects(statistics._data[entry]['cdns'], tmpCDNs);
|
||||||
statistics._dataSortedFrameworks = Object.assign(statistics._dataSortedFrameworks, statistics._data[entry]['frameworks']);
|
statistics._mergeObjects(statistics._data[entry]['frameworks'], tmpFrameworks);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
statistics._dataSortedCDNs = Object.entries(statistics._dataSortedCDNs).sort((a, b) => b[1] - a[1]);
|
statistics._dataSortedCDNs = Object.entries(tmpCDNs).sort((a, b) => b[1] - a[1]);
|
||||||
statistics._dataSortedFrameworks = Object.entries(statistics._dataSortedFrameworks).sort((a, b) => b[1] - a[1]);
|
statistics._dataSortedFrameworks = Object.entries(tmpFrameworks).sort((a, b) => b[1] - a[1]);
|
||||||
|
};
|
||||||
|
|
||||||
|
statistics._mergeObjects = function (obj, arr) {
|
||||||
|
for (let [key, value] of Object.entries(obj)) {
|
||||||
|
// If CDN/Framework exists, add it, otherwise create new one
|
||||||
|
if (arr[key]) {
|
||||||
|
arr[key] += value;
|
||||||
|
} else {
|
||||||
|
arr[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
statistics._setDateRange = function () {
|
statistics._setDateRange = function () {
|
||||||
let today = new Date();
|
let today, from, days, type;
|
||||||
let from = new Date();
|
|
||||||
let days;
|
today = new Date();
|
||||||
let type = statistics._dateUnit;
|
from = new Date();
|
||||||
|
type = statistics._dateUnit;
|
||||||
|
|
||||||
// Purge
|
// Purge
|
||||||
statistics._dateRange = [];
|
statistics._dateRange = [];
|
||||||
@ -115,9 +132,11 @@ statistics._setDateRange = function () {
|
|||||||
statistics._determineInjections = function () {
|
statistics._determineInjections = function () {
|
||||||
// NOTE: Differences between CDNs and frameworks possible.
|
// NOTE: Differences between CDNs and frameworks possible.
|
||||||
// CDN can be contacted without loading a framework.
|
// CDN can be contacted without loading a framework.
|
||||||
let sum = 0;
|
let sum, days, avg;
|
||||||
let days = 0;
|
|
||||||
let avg = 0;
|
sum = 0;
|
||||||
|
days = 0;
|
||||||
|
avg = 0;
|
||||||
statistics._dataOverview = [];
|
statistics._dataOverview = [];
|
||||||
|
|
||||||
statistics._dateRange.forEach(function (entry) {
|
statistics._dateRange.forEach(function (entry) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user