Skip to content

Commit cc8d733

Browse files
committed
Fix logs being sorted wrong
1 parent 9971ac1 commit cc8d733

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Server/Api/AccountController.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,26 @@ [FromQuery] string name
162162
query = query.Where(a => a.Username.Contains(name));
163163
}
164164

165-
var history = await query
166-
.OrderByDescending(a => a.History.Select(h => h.Time).FirstOrDefault())
165+
var results = await query.FirstOrDefaultAsync(a => a.Guid == accountGuid);
166+
167+
if (results == null)
168+
{
169+
return NotFound();
170+
}
171+
172+
results.History = results.History.OrderByDescending(h => h.Time).ToList();
173+
174+
var history = results.History
167175
.Skip(page * 10)
168176
.Take(10)
169-
.Select(a => new AccountHistoryResponse()
170-
{
171-
History = a.History,
172-
Page = page,
173-
TotalPages = (int) Math.Ceiling((double) a.History.Count / 10)
174-
})
175-
.ToListAsync();
176-
return Ok(history.First());
177+
.ToList();
178+
179+
return Ok(new AccountHistoryResponse()
180+
{
181+
History = history,
182+
Page = page,
183+
TotalPages = (int)Math.Ceiling((double)(results.History.Count / 10))
184+
});
177185
}
178186

179187
private bool IsLocal(ConnectionInfo connection)

0 commit comments

Comments
 (0)