Hotfix for LBP3 user categories being borked

This commit is contained in:
jvyden 2022-04-08 15:32:59 -04:00
commit 131add7df5
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
5 changed files with 18 additions and 13 deletions

View file

@ -119,8 +119,7 @@ public class SlotsController : ControllerBase
GameVersion gameVersion = token.GameVersion;
IQueryable<Slot> slots = this.database.Slots.ByGameVersion
(gameVersion)
IQueryable<Slot> slots = this.database.Slots.ByGameVersion(gameVersion, false, true)
.OrderByDescending(s => s.FirstUploaded)
.Skip(pageStart - 1)
.Take(Math.Min(pageSize, 30));
@ -154,7 +153,7 @@ public class SlotsController : ControllerBase
GameVersion gameVersion = token.GameVersion;
IQueryable<Slot> slots = this.database.Slots.ByGameVersion(gameVersion)
IQueryable<Slot> slots = this.database.Slots.ByGameVersion(gameVersion, false, true)
.Where(s => s.TeamPick)
.OrderByDescending(s => s.LastUpdated)
.Skip(pageStart - 1)
@ -188,7 +187,7 @@ public class SlotsController : ControllerBase
GameVersion gameVersion = token.GameVersion;
IEnumerable<Slot> slots = this.database.Slots.ByGameVersion(gameVersion).OrderBy(_ => EF.Functions.Random()).Take(Math.Min(pageSize, 30));
IEnumerable<Slot> slots = this.database.Slots.ByGameVersion(gameVersion, false, true).OrderBy(_ => EF.Functions.Random()).Take(Math.Min(pageSize, 30));
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize(gameVersion));
@ -377,7 +376,7 @@ public class SlotsController : ControllerBase
{
if (version == GameVersion.LittleBigPlanetVita || version == GameVersion.LittleBigPlanetPSP || version == GameVersion.Unknown)
{
return this.database.Slots.ByGameVersion(version);
return this.database.Slots.ByGameVersion(version, false, true);
}
string _dateFilterType = dateFilterType ?? "";

View file

@ -9,12 +9,16 @@ namespace LBPUnion.ProjectLighthouse.Helpers.Extensions;
public static class DatabaseExtensions
{
public static IQueryable<Slot> ByGameVersion
(this DbSet<Slot> set, GameVersion gameVersion, bool includeSublevels = false)
=> set.AsQueryable().ByGameVersion(gameVersion, includeSublevels);
(this DbSet<Slot> set, GameVersion gameVersion, bool includeSublevels = false, bool includeCreatorAndLocation = false)
=> set.AsQueryable().ByGameVersion(gameVersion, includeSublevels, includeCreatorAndLocation);
public static IQueryable<Slot> ByGameVersion(this IQueryable<Slot> queryable, GameVersion gameVersion, bool includeSublevels = false)
public static IQueryable<Slot> ByGameVersion
(this IQueryable<Slot> query, GameVersion gameVersion, bool includeSublevels = false, bool includeCreatorAndLocation = false)
{
IQueryable<Slot> query = queryable.Include(s => s.Creator).Include(s => s.Location);
if (includeCreatorAndLocation)
{
query = query.Include(s => s.Creator).Include(s => s.Location);
}
if (gameVersion == GameVersion.LittleBigPlanetVita || gameVersion == GameVersion.LittleBigPlanetPSP || gameVersion == GameVersion.Unknown)
{

View file

@ -17,8 +17,7 @@ public class HeartedCategory : CategoryWithUser
public override Slot? GetPreviewSlot(Database database, User user) => database.HeartedLevels.FirstOrDefault(h => h.UserId == user.UserId)?.Slot;
public override int GetTotalSlots(Database database, User user) => database.HeartedLevels.Count(h => h.UserId == user.UserId);
public override IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize)
=> database.HeartedLevels.Where
(h => h.UserId == user.UserId)
=> database.HeartedLevels.Where(h => h.UserId == user.UserId)
.Include(h => h.Slot)
.Select(h => h.Slot)
.ByGameVersion(GameVersion.LittleBigPlanet3)

View file

@ -16,6 +16,9 @@ public class NewestLevelsCategory : Category
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault();
public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3).OrderByDescending(s => s.FirstUploaded).Skip(pageStart - 1).Take(Math.Min(pageSize, 20));
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.OrderByDescending(s => s.FirstUploaded)
.Skip(pageStart - 1)
.Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count();
}

View file

@ -17,7 +17,7 @@ public class TeamPicksCategory : Category
public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion
(GameVersion.LittleBigPlanet3)
(GameVersion.LittleBigPlanet3, false, true)
.OrderByDescending(s => s.FirstUploaded)
.Where(s => s.TeamPick)
.Skip(pageStart - 1)