mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-09 13:28:39 +00:00
Fix broken LBP3 categories
This commit is contained in:
parent
886771ec3c
commit
bb1d1b835f
3 changed files with 14 additions and 13 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue