Included migrated playtime and join count in stats table

This commit is contained in:
Cooldude2606 committed 2026-10-17 16:13:17 +01:00
1 parent 383893e0cd
commit 54799ef619
2 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -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);
});
+4 -4
View File
@@ -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<lib.UserDetails, "playerStats">): Record<string, number> {
/** 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<lib.UserDetails, "playerStats">, stats: Record<string, number> = {}): Record<string, number> {
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),
};
}