add transfer stat

This commit is contained in:
Kieran 2017-11-09 23:31:31 +08:00
parent e78a2b9130
commit 365cdf4fd2
5 changed files with 16 additions and 5 deletions

View File

@ -39,7 +39,9 @@ const API = {
const Util = {
formatBytes: function (b, f) {
f = f === undefined ? 2 : f;
if (b >= 1073741824) {
if(b >= 1099511627776) {
return (b / 1099511627776.0).toFixed(f) + ' TiB';
}else if (b >= 1073741824) {
return (b / 1073741824.0).toFixed(f) + ' GiB';
} else if (b >= 1048576) {
return (b / 1048576.0).toFixed(f) + ' MiB';

View File

@ -39,7 +39,7 @@
}
.stats div {
width: 33.333%;
width: 25%;
float: left;
}
@ -54,6 +54,12 @@
line-height: 200px;
}
}
@media(max-width: 520px) {
.stats b {
display: block;
}
}
</style>
<div class="drop-zone">
Max size [[formatBytes(maxSize, 0)]]
@ -62,6 +68,7 @@
<div><b>Files:</b> [[stats.files]]</div>
<div><b>Total Size:</b> [[formatBytes(stats.size, 1)]]</div>
<div><b>Avg Size:</b> [[formatBytes(stats.avgSize, 1)]]</div>
<div><b>Transfer:</b> [[formatBytes(stats.transfer, 1)]]</div>
</div>
<template is="dom-if" if="[[expire]]">
<br/><i class="note">**Expires after [[expire]] days since last view</i>

View File

@ -16,7 +16,7 @@
margin-top: 10px;
}
@media(max-width: 470px) {
@media(max-width: 520px) {
img {
width: 100%;
}

View File

@ -30,16 +30,17 @@
{
$res = new FileStats();
$stmt = $this->mysqli->prepare("select count(hash160), sum(size), avg(size) from files");
$stmt = $this->mysqli->prepare("select count(hash160), sum(size), avg(size), sum(views * size) from files");
if($stmt)
{
$stmt->execute();
$stmt->bind_result($res->files, $res->size, $res->avgSize);
$stmt->bind_result($res->files, $res->size, $res->avgSize, $res->transfer);
$stmt->fetch();
$stmt->close();
$res->size = floatval($res->size);
$res->avgSize = floatval($res->avgSize);
$res->transfer = floatval($res->transfer);
}
return $res;

View File

@ -16,5 +16,6 @@
public $files;
public $size;
public $avgSize;
public $transfer;
}
?>