Skip to content

Commit

Permalink
fix: #dev gameRecord requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbator committed Oct 29, 2024
1 parent 2eb1e51 commit 7cb9fcd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public FileContentResult DownloadRecordData([Required] int recordedGameId)

/// <summary>Add game recording, limits are present (Auth)</summary>
/// <response code="404">User or game not found</response>
/// <response code="400">Space limit exceeded</response>
/// <response code="400">Space limit exceeded or values state cannot be empty</response>
[HttpPost]
[Authorize]
public void AddGameRecord([FromBody] [Required] RecordedGameRequest request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public byte[] DownloadRecordData(int recordedGameId, string email)

public void AddGameRecord(RecordedGameRequest request, string email)
{
var user = userDao.GetUserByEmailOrThrow(email);
if (request.Values.Count == 0 || request.Values[^1].State == null)
throw new BadRequestException("Value state cannot be empty");

var user = userDao.GetUserByEmailOrThrow(email);
if (GetSizeByUser(user.Id, request.Values.Count) > configuration.GetValue<int>("UserDataLimitMb"))
throw new BadRequestException("Space limit exceeded");

Expand All @@ -56,7 +58,7 @@ public void AddGameRecord(RecordedGameRequest request, string email)
Values = request.Values,
User = user,
Players = request.Values[0].Players,
OutputSpec = request.Values[0].OutputSpec,
OutputSpec = request.Values[0].OutputSpec ?? "",
EndState = request.Values[^1].State?.ToString()
};

Expand Down
2 changes: 1 addition & 1 deletion rag-2-backend/Infrastructure/Module/Stats/StatsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public UserStatsResponse GetStatsForUser(string email, int userId)
{
var principal = _context.Users.FirstOrDefault(u => u.Email == email)
?? throw new NotFoundException("User not found");

var user = _context.Users.FirstOrDefault(u => u.Id == userId)
?? throw new NotFoundException("User not found");

Expand Down

0 comments on commit 7cb9fcd

Please sign in to comment.