mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 10:08:39 +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
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -29,6 +30,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
|||
|
||||
public abstract Slot? GetPreviewSlot(Database database);
|
||||
|
||||
public abstract int GetTotalSlots(Database database);
|
||||
|
||||
public string Serialize(Database database)
|
||||
{
|
||||
Slot? previewSlot = this.GetPreviewSlot(database);
|
||||
|
@ -36,7 +39,20 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
|||
string previewResults = "";
|
||||
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
|
||||
|
|
|
@ -11,5 +11,6 @@ namespace LBPUnion.ProjectLighthouse.Types.Categories
|
|||
public override string IconHash { get; set; } = "g820623";
|
||||
public override string Endpoint { get; set; } = "newest";
|
||||
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
|
||||
(Database database)
|
||||
public override Slot? GetPreviewSlot(Database database)
|
||||
=> 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 Endpoint { get; set; } = "team_picks";
|
||||
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