Fix broken LBP3 categories

This commit is contained in:
Slendy 2023-02-05 21:06:05 -06:00
commit bb1d1b835f
No known key found for this signature in database
GPG key ID: 7288D68361B91428
3 changed files with 14 additions and 13 deletions

View file

@ -2,10 +2,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.PlayerData;
using Microsoft.EntityFrameworkCore;
using YamlDotNet.Core.Tokens;
namespace LBPUnion.ProjectLighthouse.Levels.Categories;
@ -15,13 +14,13 @@ public class HighestRatedCategory : Category
public override string Description { get; set; } = "Community Highest Rated content";
public override string IconHash { get; set; } = "g820603";
public override string Endpoint { get; set; } = "thumbs";
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().OrderByDescending(s => s.Thumbsup).FirstOrDefault();
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Thumbsup);
public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.AsEnumerable()
.AsEnumerable()
.OrderByDescending(s => s.Thumbsup)
.ThenBy(_ => EF.Functions.Random())
.ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue))
.Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);

View file

@ -2,9 +2,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.PlayerData;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Levels.Categories;
@ -18,9 +18,9 @@ public class MostHeartedCategory : Category
public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.AsEnumerable()
.AsEnumerable()
.OrderByDescending(s => s.Hearts)
.ThenBy(_ => EF.Functions.Random())
.ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue))
.Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);

View file

@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Linq;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.PlayerData;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Levels.Categories;
@ -14,13 +13,16 @@ public class MostPlayedCategory : Category
public override string Description { get; set; } = "The most played content";
public override string IconHash { get; set; } = "g820608";
public override string Endpoint { get; set; } = "mostUniquePlays";
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.PlaysUnique);
public override Slot? GetPreviewSlot(Database database) => database.Slots
.Where(s => s.Type == SlotType.User)
.OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique)
.ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3)
.FirstOrDefault();
public override IEnumerable<Slot> GetSlots
(Database database, int pageStart, int pageSize)
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
.AsEnumerable()
.OrderByDescending(s => s.PlaysUnique)
.ThenBy(_ => EF.Functions.Random())
.OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique)
.ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3)
.Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 20));
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);