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
@@ -1122,7 +1122,7 @@ namespace DorkNet.Server.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Channel");
b.HasKey("RoomId", "Channel");
b.HasIndex("RoomId");
@@ -1138,6 +1138,9 @@ namespace DorkNet.Server.Migrations
b.Property<long>("PlayerId")
.HasColumnType("INTEGER");
b.Property<long>("RoomId")
.HasColumnType("INTEGER");
b.Property<int>("StatChannel")
.HasColumnType("INTEGER");
@@ -1149,10 +1152,10 @@ namespace DorkNet.Server.Migrations
b.HasKey("Id");
b.HasIndex("PlayerId", "StatChannel")
b.HasIndex("RoomId", "PlayerId", "StatChannel")
.IsUnique();
b.HasIndex("StatChannel", "Value");
b.HasIndex("RoomId", "StatChannel", "Value");
b.ToTable("LeaderboardStats");
});
@@ -516,7 +516,7 @@ namespace DorkNet.Server.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_LeaderboardChannelMeta", x => x.Channel);
table.PrimaryKey("PK_LeaderboardChannelMeta", x => new { x.RoomId, x.Channel });
});
migrationBuilder.CreateTable(
@@ -526,6 +526,7 @@ namespace DorkNet.Server.Migrations
Id = table.Column<long>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
PlayerId = table.Column<long>(type: "INTEGER", nullable: false),
RoomId = table.Column<long>(type: "INTEGER", nullable: false),
StatChannel = table.Column<int>(type: "INTEGER", nullable: false),
Value = table.Column<long>(type: "INTEGER", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
@@ -1550,15 +1551,15 @@ namespace DorkNet.Server.Migrations
column: "RoomId");
migrationBuilder.CreateIndex(
name: "IX_LeaderboardStats_PlayerId_StatChannel",
name: "IX_LeaderboardStats_RoomId_PlayerId_StatChannel",
table: "LeaderboardStats",
columns: new[] { "PlayerId", "StatChannel" },
columns: new[] { "RoomId", "PlayerId", "StatChannel" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_LeaderboardStats_StatChannel_Value",
name: "IX_LeaderboardStats_RoomId_StatChannel_Value",
table: "LeaderboardStats",
columns: new[] { "StatChannel", "Value" });
columns: new[] { "RoomId", "StatChannel", "Value" });
migrationBuilder.CreateIndex(
name: "IX_Messages_RecipientPlayerId_SentAt",
@@ -1119,7 +1119,7 @@ namespace DorkNet.Server.Migrations
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Channel");
b.HasKey("RoomId", "Channel");
b.HasIndex("RoomId");
@@ -1135,6 +1135,9 @@ namespace DorkNet.Server.Migrations
b.Property<long>("PlayerId")
.HasColumnType("INTEGER");
b.Property<long>("RoomId")
.HasColumnType("INTEGER");
b.Property<int>("StatChannel")
.HasColumnType("INTEGER");
@@ -1146,10 +1149,10 @@ namespace DorkNet.Server.Migrations
b.HasKey("Id");
b.HasIndex("PlayerId", "StatChannel")
b.HasIndex("RoomId", "PlayerId", "StatChannel")
.IsUnique();
b.HasIndex("StatChannel", "Value");
b.HasIndex("RoomId", "StatChannel", "Value");
b.ToTable("LeaderboardStats");
});