top list hr strings
This commit is contained in:
@@ -31,7 +31,7 @@ namespace g {
|
||||
|
||||
namespace c {
|
||||
const QString SOFTWARE_NAME = "3proxy-eagle";
|
||||
const QString SOFTWARE_VERSION = "0.0.1a";
|
||||
const QString SOFTWARE_VERSION = "0.0.1";
|
||||
const QString COPYRIGHT = "GPLv3 (c) acetone, 2022";
|
||||
const qint64 DB_DAILY_TOP_TABLE_ACTUALIZE_MINIMAL_INTERVAL_MS = 300000; // 5 min
|
||||
const qint64 CACHE_ACTUALIZE_TOP_LISTS_FROM_DB_MINIMAL_INTERVAL_MS = 5000; // 5 sec
|
||||
|
||||
+64
-17
@@ -319,7 +319,7 @@ QString WebPage::topDestinationItem(const QString &destination, quint64 count)
|
||||
{
|
||||
QString result {m_topDestinationItem};
|
||||
result.replace("{{VALUE}}", destination);
|
||||
result.replace("{{COUNT}}", QString::number(count));
|
||||
result.replace("{{COUNT}}", counterToHumanReadableString(count));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -342,47 +342,47 @@ HumanReadableValue WebPage::bytesToHumanReadableString(quint64 bytes)
|
||||
{
|
||||
HumanReadableValue result;
|
||||
|
||||
constexpr const quint64 BYTE = 1024;
|
||||
constexpr const quint64 KBYTE = 1024;
|
||||
|
||||
if (bytes < BYTE)
|
||||
if (bytes < KBYTE)
|
||||
{
|
||||
result.integer = QString::number(bytes);
|
||||
result.decimal = "0";
|
||||
result.measure = "B";
|
||||
}
|
||||
|
||||
else if (bytes <= BYTE*BYTE)
|
||||
else if (bytes <= KBYTE*KBYTE)
|
||||
{
|
||||
result.integer = QString::number(bytes/BYTE);
|
||||
result.decimal = QString::number(bytes%BYTE);
|
||||
result.integer = QString::number(bytes/KBYTE);
|
||||
result.decimal = QString::number(bytes%KBYTE);
|
||||
result.measure = "KiB";
|
||||
}
|
||||
|
||||
else if (bytes <= BYTE*BYTE*BYTE)
|
||||
else if (bytes <= KBYTE*KBYTE*KBYTE)
|
||||
{
|
||||
result.integer = QString::number(bytes /BYTE/BYTE);
|
||||
result.decimal = QString::number(bytes% (BYTE*BYTE));
|
||||
result.integer = QString::number(bytes /KBYTE/KBYTE);
|
||||
result.decimal = QString::number(bytes% (KBYTE*KBYTE));
|
||||
result.measure = "MiB";
|
||||
}
|
||||
|
||||
else if (bytes <= BYTE*BYTE*BYTE*BYTE)
|
||||
else if (bytes <= KBYTE*KBYTE*KBYTE*KBYTE)
|
||||
{
|
||||
result.integer = QString::number(bytes /BYTE/BYTE/BYTE);
|
||||
result.decimal = QString::number(bytes% (BYTE*BYTE*BYTE));
|
||||
result.integer = QString::number(bytes /KBYTE/KBYTE/KBYTE);
|
||||
result.decimal = QString::number(bytes% (KBYTE*KBYTE*KBYTE));
|
||||
result.measure = "GiB";
|
||||
}
|
||||
|
||||
else if (bytes <= BYTE*BYTE*BYTE*BYTE*BYTE)
|
||||
else if (bytes <= KBYTE*KBYTE*KBYTE*KBYTE*KBYTE)
|
||||
{
|
||||
result.integer = QString::number(bytes /BYTE/BYTE/BYTE/BYTE);
|
||||
result.decimal = QString::number(bytes% (BYTE*BYTE*BYTE*BYTE));
|
||||
result.integer = QString::number(bytes /KBYTE/KBYTE/KBYTE/KBYTE);
|
||||
result.decimal = QString::number(bytes% (KBYTE*KBYTE*KBYTE*KBYTE));
|
||||
result.measure = "TiB";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
result.integer = QString::number(bytes /BYTE/BYTE/BYTE/BYTE/BYTE);
|
||||
result.decimal = QString::number(bytes% (BYTE*BYTE*BYTE*BYTE*BYTE));
|
||||
result.integer = QString::number(bytes /KBYTE/KBYTE/KBYTE/KBYTE/KBYTE);
|
||||
result.decimal = QString::number(bytes% (KBYTE*KBYTE*KBYTE*KBYTE*KBYTE));
|
||||
result.integer = "PiB";
|
||||
}
|
||||
|
||||
@@ -399,3 +399,50 @@ HumanReadableValue WebPage::bytesToHumanReadableString(quint64 bytes)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString WebPage::counterToHumanReadableString(quint64 count)
|
||||
{
|
||||
constexpr const quint64 THOUSAND = 1000;
|
||||
|
||||
QString result;
|
||||
|
||||
if (count < THOUSAND)
|
||||
{
|
||||
result = QString::number(count);
|
||||
}
|
||||
|
||||
else if (count <= THOUSAND*THOUSAND)
|
||||
{
|
||||
result = QString::number(count/THOUSAND);
|
||||
auto decimal = count%THOUSAND;
|
||||
if (decimal)
|
||||
{
|
||||
result += "." + QString::number(decimal).mid(0,1);
|
||||
}
|
||||
result += " K";
|
||||
}
|
||||
|
||||
else if (count <= THOUSAND*THOUSAND*THOUSAND)
|
||||
{
|
||||
result = QString::number(count /THOUSAND/THOUSAND);
|
||||
auto decimal = count% (THOUSAND*THOUSAND);
|
||||
if (decimal)
|
||||
{
|
||||
result += "." + QString::number(decimal).mid(0,1);
|
||||
}
|
||||
result += " M";
|
||||
}
|
||||
|
||||
else if (count <= THOUSAND*THOUSAND*THOUSAND*THOUSAND)
|
||||
{
|
||||
result = QString::number(count /THOUSAND/THOUSAND/THOUSAND);
|
||||
auto decimal = count% (THOUSAND*THOUSAND*THOUSAND);
|
||||
if (decimal)
|
||||
{
|
||||
result += "." + QString::number(decimal).mid(0,1);
|
||||
}
|
||||
result += " B";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ private:
|
||||
static QString topDestinationItem(const QString& destination, quint64 count);
|
||||
static QString blockedDestinationItem(const QString& destination, const QStringList& addresses);
|
||||
static HumanReadableValue bytesToHumanReadableString(quint64 bytes);
|
||||
static QString counterToHumanReadableString(quint64 count);
|
||||
|
||||
static const QString m_lastDestinationItemAllowed;
|
||||
static const QString m_lastDestinationItemBlocked;
|
||||
|
||||
Reference in New Issue
Block a user