Order suggestions client-side to avoid SQLite DateTimeOffset ORDER BY
This commit is contained in:
21
Program.cs
21
Program.cs
@@ -177,6 +177,20 @@ api.MapGet("/suggestions/all", async (AppDbContext db) =>
|
|||||||
|
|
||||||
var all = await db.Suggestions.AsNoTracking()
|
var all = await db.Suggestions.AsNoTracking()
|
||||||
.Include(s => s.Player)
|
.Include(s => s.Player)
|
||||||
|
.Select(s => new
|
||||||
|
{
|
||||||
|
s.Id,
|
||||||
|
s.Name,
|
||||||
|
s.Genre,
|
||||||
|
s.Description,
|
||||||
|
s.ScreenshotUrl,
|
||||||
|
s.YoutubeUrl,
|
||||||
|
Author = s.Player!.DisplayName,
|
||||||
|
s.CreatedAt
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var ordered = all
|
||||||
.OrderBy(s => s.CreatedAt)
|
.OrderBy(s => s.CreatedAt)
|
||||||
.Select(s => new
|
.Select(s => new
|
||||||
{
|
{
|
||||||
@@ -186,11 +200,10 @@ api.MapGet("/suggestions/all", async (AppDbContext db) =>
|
|||||||
s.Description,
|
s.Description,
|
||||||
s.ScreenshotUrl,
|
s.ScreenshotUrl,
|
||||||
s.YoutubeUrl,
|
s.YoutubeUrl,
|
||||||
Author = s.Player!.DisplayName
|
s.Author
|
||||||
})
|
});
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
return Results.Ok(all);
|
return Results.Ok(ordered);
|
||||||
});
|
});
|
||||||
|
|
||||||
api.MapGet("/votes/mine", async (HttpContext ctx, AppDbContext db) =>
|
api.MapGet("/votes/mine", async (HttpContext ctx, AppDbContext db) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user