mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
fix: calculations for admin user being done incrrectly
This commit is contained in:
parent
f5a5b13ddf
commit
559f24b8d8
@ -24,6 +24,10 @@ public class AdminUsersController:ControllerBase
|
||||
public async Task<IActionResult> GetUsers([FromQuery]string search="", [FromQuery]int offset = 0, [FromQuery]int pageSize = 10)
|
||||
{
|
||||
var users = await _dbContext.Users
|
||||
.Include(x=>x.Requests)
|
||||
.Include(x=>x.Suspensions)
|
||||
.Include(x=>x.Bans)
|
||||
.Include(x=>x.Requests).ThenInclude(x=>x.Artist)
|
||||
.Where(x=>x.DisplayName.Contains(search) || x.Email.Contains(search))
|
||||
.Skip(offset).Take(pageSize).ToListAsync();
|
||||
var result = users.Select(x => x.ToAdminUserModel());
|
||||
@ -42,7 +46,12 @@ public class AdminUsersController:ControllerBase
|
||||
[HttpGet("{userId}")]
|
||||
public async Task<IActionResult> GetUser(string userId)
|
||||
{
|
||||
var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId);
|
||||
var user = await _dbContext.Users
|
||||
.Include(x=>x.Requests)
|
||||
.Include(x=>x.Suspensions)
|
||||
.Include(x=>x.Bans)
|
||||
.Include(x=>x.Requests).ThenInclude(x=>x.Artist)
|
||||
.FirstOrDefaultAsync(x=>x.Id==userId);
|
||||
|
||||
if (user == null)
|
||||
return NotFound();
|
||||
|
@ -28,7 +28,7 @@ public static class AdminUserModelExtensions
|
||||
NumberOfRequests = user.Requests.Count,
|
||||
NumberOfSuspensions = user.Suspensions.Count,
|
||||
NumberOfBans = user.Bans.Count,
|
||||
NumberOfReviews = user.Requests.Count,
|
||||
NumberOfReviews = user.Requests.Count(x => x.Reviewed),
|
||||
AmountSpent = user.Requests.Sum(r => r.Amount)
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user