mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-03 10:38:40 +00:00
Fix category slot serialization bug
This commit is contained in:
parent
f8c02cb3aa
commit
c3d4a97565
4 changed files with 22 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
@ -29,6 +30,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||||
|
|
||||||
public abstract Slot? GetPreviewSlot(Database database);
|
public abstract Slot? GetPreviewSlot(Database database);
|
||||||
|
|
||||||
|
public abstract int GetTotalSlots(Database database);
|
||||||
|
|
||||||
public string Serialize(Database database)
|
public string Serialize(Database database)
|
||||||
{
|
{
|
||||||
Slot? previewSlot = this.GetPreviewSlot(database);
|
Slot? previewSlot = this.GetPreviewSlot(database);
|
||||||
|
@ -36,7 +39,20 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||||
string previewResults = "";
|
string previewResults = "";
|
||||||
if (previewSlot != null)
|
if (previewSlot != null)
|
||||||
{
|
{
|
||||||
previewResults = LbpSerializer.StringElement("results", LbpSerializer.StringElement("slots", previewSlot.Serialize()));
|
previewResults = LbpSerializer.TaggedStringElement
|
||||||
|
(
|
||||||
|
"results",
|
||||||
|
previewSlot.Serialize(),
|
||||||
|
new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"total", this.GetTotalSlots(database)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hint_start", "2"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LbpSerializer.StringElement
|
return LbpSerializer.StringElement
|
||||||
|
|
|
@ -11,5 +11,6 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||||
public override string IconHash { get; set; } = "g820623";
|
public override string IconHash { get; set; } = "g820623";
|
||||||
public override string Endpoint { get; set; } = "newest";
|
public override string Endpoint { get; set; } = "newest";
|
||||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault();
|
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault();
|
||||||
|
public override int GetTotalSlots(Database database) => database.Slots.Count();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,8 +25,9 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Slot? GetPreviewSlot
|
public override Slot? GetPreviewSlot(Database database)
|
||||||
(Database database)
|
|
||||||
=> database.QueuedLevels.Include(q => q.Slot).FirstOrDefault(q => q.UserId == this.user.UserId)?.Slot;
|
=> database.QueuedLevels.Include(q => q.Slot).FirstOrDefault(q => q.UserId == this.user.UserId)?.Slot;
|
||||||
|
|
||||||
|
public override int GetTotalSlots(Database database) => database.QueuedLevels.Count(q => q.UserId == this.user.UserId);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,5 +11,6 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||||
public override string IconHash { get; set; } = "g820626";
|
public override string IconHash { get; set; } = "g820626";
|
||||||
public override string Endpoint { get; set; } = "team_picks";
|
public override string Endpoint { get; set; } = "team_picks";
|
||||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(s => s.TeamPick);
|
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(s => s.TeamPick);
|
||||||
|
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.TeamPick);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue