Extend statistics over the whole time range (#1626)

This commit is contained in:
nobody 2024-04-28 08:09:56 +02:00
parent c3a821c32a
commit e04c723de5
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
3 changed files with 13 additions and 1 deletions

View File

@ -23,6 +23,7 @@
<option value="week" data-i18n-content="labelPastWeek">Past week</option>
<option value="month" data-i18n-content="labelPastMonth">Past month</option>
<option value="year" data-i18n-content="labelPastYear">Past year</option>
<option value="all" data-i18n-content="labelAll">All</option>
</select>
<div id="btn-delete" class="button" data-i18n-content="labelDelete">Delete</div>
</div>

View File

@ -127,6 +127,8 @@ statistics._setDateRange = function () {
days = 30;
} else if (type === 'year') {
days = 365;
} else if (type === 'all') {
days = statistics._daysSinceFirstRelease();
} else {
statistics._dateRange = [new Date().toISOString().slice(0, 10)];
}
@ -238,7 +240,7 @@ statistics._displayNameOfFramework = function (str, type) {
statistics._handlerDateRange = function ({target}) {
let type = target.value;
if (type === 'day' || type === 'week' || type === 'month' || type === 'year') {
if (type === 'day' || type === 'week' || type === 'month' || type === 'year' || type === 'all') {
statistics._dateUnit = type;
statistics._saveDefaultRange(type);
} else if (type === 'delete') {
@ -270,6 +272,14 @@ statistics._registerListener = function () {
});
};
statistics._daysSinceFirstRelease = function () {
let timeDifference, millisecondsPerDay;
timeDifference = new Date() - new Date('2020-01-01');
millisecondsPerDay = 24 * 60 * 60 * 1000;
return Math.floor(timeDifference / millisecondsPerDay);
};
/**
* Initializations

View File

@ -32,6 +32,7 @@
<p>Improved</p>
<ul>
<li>Wildcard support extended in all lists (<a href="https://codeberg.org/nobody/LocalCDN/issues/1622">#1622</a>)</li>
<li>Extend statistics over the whole time range (<a href="https://codeberg.org/nobody/LocalCDN/issues/1626">#1626</a>)</li>
</ul>
<p>Fixed</p>
<ul>