Make lucky dip actually random

This commit is contained in:
jvyden 2021-11-09 21:25:39 -05:00
parent ac40dd041a
commit 4b2db48550
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278

View file

@ -117,13 +117,14 @@ namespace LBPUnion.ProjectLighthouse.Controllers
GameVersion gameVersion = token.GameVersion; GameVersion gameVersion = token.GameVersion;
// TODO: Incorporate seed? // TODO: Incorporate seed?
IQueryable<Slot> slots = this.database.Slots.Where(s => s.GameVersion <= gameVersion) IOrderedEnumerable<Slot> slots = this.database.Slots.Where(s => s.GameVersion <= gameVersion)
.OrderBy(_ => Guid.NewGuid())
.Include(s => s.Creator) .Include(s => s.Creator)
.Include(s => s.Location) .Include(s => s.Location)
.Skip(pageStart - 1) .Skip(pageStart - 1)
.Take(Math.Min(pageSize, 30)); .Take(Math.Min(pageSize, 30))
string response = Enumerable.Aggregate(slots, string.Empty, (current, slot) => current + slot.Serialize()); .AsEnumerable()
.OrderBy(_ => Guid.NewGuid());
string response = slots.Aggregate(string.Empty, (current, slot) => current + slot.Serialize());
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "hint_start", pageStart + Math.Min(pageSize, 30))); return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "hint_start", pageStart + Math.Min(pageSize, 30)));
} }