Refactor leaderboard logic: incorporate room context into leaderboard stats and channel metadata handling

This commit is contained in:
Alexa
2026-06-05 23:55:26 +03:00
parent 97e0fa5716
commit fe1c2c53e3
10 changed files with 257 additions and 106 deletions
@@ -1,7 +1,8 @@
namespace DorkNet.Server.Data.Entities;
/// <summary>
/// Admin-curated metadata for a leaderboard <c>StatChannel</c> id. The
/// Admin-curated metadata for a room-scoped leaderboard
/// <c>StatChannel</c> id. The
/// 2020 watch reports raw integer channel ids via
/// <c>POST api/Leaderboard/v1/SetStats</c>; this table lets admins map
/// each channel to a specific room (so the room detail page can list
@@ -9,22 +10,19 @@ namespace DorkNet.Server.Data.Entities;
/// here override the hardcoded <c>AdminController.KnownStatChannels</c>
/// fallback. Channels with no row stay listed as "Channel N".
///
/// One channel id, one row. Repeated <c>SetStats</c> calls for the same
/// channel from any room write to that channel's value rows; the meta
/// row only changes when an admin renames or re-maps it.
/// One row per (room, channel). Repeated <c>SetStats</c> calls for the
/// same channel in different rooms do not share metadata or values.
/// </summary>
public class LeaderboardChannelMetaEntity
{
/// <summary>Same int the watch reports for this channel. Primary
/// key — there's only ever one meta row per channel.</summary>
public int Channel { get; set; }
/// <summary>Room this channel "belongs to" for the per-room detail
/// view. 0 = global / unscoped (e.g. cross-room player progression
/// counters). The same room can own many channels (e.g. Stunt
/// Runner has one channel per course).</summary>
/// view. 0 = global / unscoped legacy bucket.</summary>
public long RoomId { get; set; }
/// <summary>Same int the watch reports for this channel. Only unique
/// together with <see cref="RoomId"/>.</summary>
public int Channel { get; set; }
public string Name { get; set; } = string.Empty;
/// <summary>When true, a lower stored value is a better score (race