refac,wip: refresh 수치를 이전 중

- connect, con을 잊었음!
This commit is contained in:
2023-07-07 10:57:51 +00:00
parent a9b51977d4
commit 9bf7bd0fda
9 changed files with 14 additions and 61 deletions
+13 -4
View File
@@ -2,6 +2,8 @@
namespace sammo;
use sammo\Enums\GeneralAccessLogColumn;
include "lib.php";
include "func.php";
@@ -193,12 +195,19 @@ if ($admin['maxonline'] < $curonline) {
</td>
</tr>
<?php
$max_refresh = $db->queryFirstRow('SELECT sum(refresh) as refresh, sum(`connect`) as `connect` from general');
$max_refresh['name'] = '접속자 총합';
$totalRefresh = [
'connect' => $db->queryFirstField('SELECT sum(`connect`) as `connect` from general'),
'refresh' => $db->queryFirstField('SELECT sum(`refresh`) as `refresh` from general_access_log'),
'name' => '접속자 총합'
];
$refresh_result = array_merge([$max_refresh], $db->query('SELECT `name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5'));
$top5Refresh = $db->query(
'SELECT `name`, `log`.`refresh`, `connect` FROM `general_access_log` AS `log`
INNER JOIN `general` ON `log`.`general_id` = `general`.`no` ORDER BY `log`.`refresh` DESC LIMIT 5');
foreach ($refresh_result as $i => $user) {
$refresh_result = array_merge([$max_refresh], $db->query('SELECT `no`,`name`,refresh,`connect` FROM general ORDER BY refresh DESC LIMIT 5'));
foreach (array_merge([$totalRefresh], $top5Refresh) as $i => $user) {
$w = round($user['refresh'] / max(1, $max_refresh['refresh']) * 100, 1);
$w2 = round(100 - $w, 1);
$color = getTrafficColor($w);
+1 -19
View File
@@ -1069,9 +1069,6 @@ function updateTraffic()
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']);
/** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */
//최다갱신자
$user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1');
if ($admin['maxrefresh'] < $admin['refresh']) {
$admin['maxrefresh'] = $admin['refresh'];
}
@@ -1082,22 +1079,7 @@ function updateTraffic()
$gameStor->maxrefresh = $admin['maxrefresh'];
$gameStor->maxonline = $admin['maxonline'];
$db->update('general', ['refresh' => 0], true);
$date = TimeUtil::now();
//일시|년|월|총갱신|접속자|최다갱신자
file_put_contents(
__DIR__ . "/logs/" . UniqueConst::$serverID . "/_traffic.txt",
Json::encode([
$date,
$admin['year'],
$admin['month'],
$admin['refresh'],
$online,
$user['name'] . "(" . $user['refresh'] . ")"
]) . "\n",
FILE_APPEND
);
$db->update('general_access_log', ['refresh' => 0], true);
}
function CheckOverhead()
-1
View File
@@ -430,7 +430,6 @@ class Join extends \sammo\BaseAPI
$db->insert('general_access_log', [
GeneralAccessLogColumn::generalID->value => $generalID,
GeneralAccessLogColumn::userID->value => $userID,
GeneralAccessLogColumn::nationID->value => 1,
GeneralAccessLogColumn::lastRefresh->value => $now,
]);
-11
View File
@@ -19,21 +19,10 @@ class GeneralAccessLog extends \LDTO\DTO
#[RawName('user_id')]
public ?int $userID,
#[RawName('nation_id')]
#[NullIsUndefined]
public ?int $nationID,
#[RawName('last_refresh')]
#[Convert(DateTimeConverter::class)]
public \DateTimeImmutable $lastRefresh,
#[RawName('last_connect')]
#[Convert(DateTimeConverter::class)]
public ?\DateTimeImmutable $lastConnect,
#[RawName('login_total')]
public int $loginTotal,
public int $refresh,
#[RawName('refresh_total')]
@@ -6,10 +6,7 @@ enum GeneralAccessLogColumn: string {
case id = 'id';
case generalID = 'general_id';
case userID = 'user_id';
case nationID = 'nation_id';
case lastRefresh = 'last_refresh';
case lastConnect = 'last_connect';
case loginTotal = 'login_total';
case refresh = 'refresh';
case refreshTotal = 'refresh_total';
}
-3
View File
@@ -17,9 +17,6 @@ enum GeneralColumn: string{
case newmsg = 'newmsg';
case con = 'con';
case connect = 'connect';
case refresh = 'refresh';
case logcnt = 'logcnt';
case refcnt = 'refcnt';
case picture = 'picture';
case imgsvr = 'imgsvr';
case name = 'name';
-6
View File
@@ -793,12 +793,6 @@ class General implements iAction
'nation_id' => $updateVals['nation']
], 'general_id = %i', $generalID);
$result = true;
if($this->getNPCType() < 2){
$db->update('general_access_log', [
GeneralAccessLogColumn::nationID->value => $updateVals['nation']
], '%b = %i', GeneralAccessLogColumn::generalID->value, $generalID);
}
}
$this->flushUpdateValues();
}
-8
View File
@@ -13,9 +13,6 @@ CREATE TABLE `general` (
`newmsg` INT(1) NULL DEFAULT '0',
`con` INT(6) NOT NULL DEFAULT '0',
`connect` INT(6) NOT NULL DEFAULT '0',
`refresh` INT(6) NOT NULL DEFAULT '0',
`logcnt` INT(6) NULL DEFAULT '1',
`refcnt` INT(6) NULL DEFAULT '1',
`picture` VARCHAR(40) NOT NULL,
`imgsvr` INT(1) NOT NULL DEFAULT '0',
`name` VARCHAR(32) NOT NULL COLLATE 'utf8mb4_bin',
@@ -54,7 +51,6 @@ CREATE TABLE `general` (
`recent_war` DATETIME(6) NULL DEFAULT NULL,
`makelimit` INT(2) NULL DEFAULT '0',
`killturn` INT(3) NULL DEFAULT NULL,
`ip` VARCHAR(40) NULL DEFAULT '',
`block` INT(1) NULL DEFAULT '0',
`dedlevel` INT(2) NULL DEFAULT '0',
`explevel` INT(2) NULL DEFAULT '0',
@@ -103,15 +99,11 @@ CREATE TABLE `general_access_log` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`general_id` INT(11) NOT NULL,
`user_id` INT(11) NULL DEFAULT NULL,
`nation_id` INT(11) NULL DEFAULT NULL,
`last_refresh` DATETIME NULL DEFAULT NULL,
`last_connect` DATETIME NULL DEFAULT NULL,
`login_total` INT(11) NOT NULL DEFAULT '0',
`refresh` INT(11) NOT NULL DEFAULT '0',
`refresh_total` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE INDEX `general_id` (`general_id`),
INDEX `nation_id` (`nation_id`)
)
COLLATE='utf8mb4_general_ci'
ENGINE=Aria
-6
View File
@@ -288,12 +288,6 @@ class Session
}
}
$db->update('general', [
'logcnt' => $db->sqleval('logcnt+1'),
'ip' => Util::get_client_ip(true),
'lastConnect' => TimeUtil::now()
], 'owner = %i', $userID);
$this->set($serverID.static::GAME_KEY_DATE, $now);
$this->set($serverID.static::GAME_KEY_GENERAL_ID, $generalID);
$this->set($serverID.static::GAME_KEY_GENERAL_NAME, $generalName);