diff --git a/ProjectLighthouse/Controllers/GameApi/Slots/SlotsController.cs b/ProjectLighthouse/Controllers/GameApi/Slots/SlotsController.cs index 9d89570a..a9aff2f3 100644 --- a/ProjectLighthouse/Controllers/GameApi/Slots/SlotsController.cs +++ b/ProjectLighthouse/Controllers/GameApi/Slots/SlotsController.cs @@ -119,8 +119,7 @@ public class SlotsController : ControllerBase GameVersion gameVersion = token.GameVersion; - IQueryable slots = this.database.Slots.ByGameVersion - (gameVersion) + IQueryable 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 slots = this.database.Slots.ByGameVersion(gameVersion) + IQueryable 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 slots = this.database.Slots.ByGameVersion(gameVersion).OrderBy(_ => EF.Functions.Random()).Take(Math.Min(pageSize, 30)); + IEnumerable 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 ?? ""; diff --git a/ProjectLighthouse/Helpers/Extensions/DatabaseExtensions.cs b/ProjectLighthouse/Helpers/Extensions/DatabaseExtensions.cs index 5d346c24..5b656aac 100644 --- a/ProjectLighthouse/Helpers/Extensions/DatabaseExtensions.cs +++ b/ProjectLighthouse/Helpers/Extensions/DatabaseExtensions.cs @@ -9,12 +9,16 @@ namespace LBPUnion.ProjectLighthouse.Helpers.Extensions; public static class DatabaseExtensions { public static IQueryable ByGameVersion - (this DbSet set, GameVersion gameVersion, bool includeSublevels = false) - => set.AsQueryable().ByGameVersion(gameVersion, includeSublevels); + (this DbSet set, GameVersion gameVersion, bool includeSublevels = false, bool includeCreatorAndLocation = false) + => set.AsQueryable().ByGameVersion(gameVersion, includeSublevels, includeCreatorAndLocation); - public static IQueryable ByGameVersion(this IQueryable queryable, GameVersion gameVersion, bool includeSublevels = false) + public static IQueryable ByGameVersion + (this IQueryable query, GameVersion gameVersion, bool includeSublevels = false, bool includeCreatorAndLocation = false) { - IQueryable 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) { diff --git a/ProjectLighthouse/Types/Categories/HeartedCategory.cs b/ProjectLighthouse/Types/Categories/HeartedCategory.cs index 24b9e12c..bf7a1ab3 100644 --- a/ProjectLighthouse/Types/Categories/HeartedCategory.cs +++ b/ProjectLighthouse/Types/Categories/HeartedCategory.cs @@ -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 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) diff --git a/ProjectLighthouse/Types/Categories/NewestLevelsCategory.cs b/ProjectLighthouse/Types/Categories/NewestLevelsCategory.cs index 492c66e8..8ea917c5 100644 --- a/ProjectLighthouse/Types/Categories/NewestLevelsCategory.cs +++ b/ProjectLighthouse/Types/Categories/NewestLevelsCategory.cs @@ -16,6 +16,9 @@ public class NewestLevelsCategory : Category public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(); public override IEnumerable 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(); } \ No newline at end of file diff --git a/ProjectLighthouse/Types/Categories/TeamPicksCategory.cs b/ProjectLighthouse/Types/Categories/TeamPicksCategory.cs index 3c719553..87566a1c 100644 --- a/ProjectLighthouse/Types/Categories/TeamPicksCategory.cs +++ b/ProjectLighthouse/Types/Categories/TeamPicksCategory.cs @@ -17,7 +17,7 @@ public class TeamPicksCategory : Category public override IEnumerable 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)