From 54799ef61943fdac380369d6a7abf4999bbc0bed Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Sat, 17 Oct 2026 16:13:17 +0100 Subject: [PATCH] Included migrated playtime and join count in stats table --- exp_player_statistics/controller.ts | 2 +- exp_player_statistics/messages.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/exp_player_statistics/controller.ts b/exp_player_statistics/controller.ts index 21bd1f95..815eb124 100644 --- a/exp_player_statistics/controller.ts +++ b/exp_player_statistics/controller.ts @@ -49,7 +49,7 @@ export default async function (context: ControllerPluginContext) { const record = players.get(request.name); return new messages.PlayerStatistics(request.name, { ...record?.stats, - ...messages.userStatistics(controller.users.getByName(request.name)), + ...messages.userStatistics(controller.users.getByName(request.name), record?.stats), }, record?.updatedAtMs); }); diff --git a/exp_player_statistics/messages.ts b/exp_player_statistics/messages.ts index ad6f8da3..d984d55f 100644 --- a/exp_player_statistics/messages.ts +++ b/exp_player_statistics/messages.ts @@ -42,11 +42,11 @@ export class PlayerStatistics { } } -/** Statistics clusterio already keeps for every user, shown with the others but never added to */ -export function userStatistics(user?: Pick): Record { +/** Statistics clusterio already keeps for every user, shown with the others but never added to, existing stats may contain legacy values */ +export function userStatistics(user?: Pick, stats: Record = {}): Record { return { - Playtime: Math.floor((user?.playerStats.onlineTimeMs ?? 0) / 60e3), - JoinCount: user?.playerStats.joinCount ?? 0, + Playtime: (stats.Playtime ?? 0) + Math.floor((user?.playerStats.onlineTimeMs ?? 0) / 60e3), + JoinCount: (stats.JoinCount ?? 0) + (user?.playerStats.joinCount ?? 0), }; }