Skip to content

Commit 4ffead7

Browse files
committed
prep pwa upload
1 parent 11ba843 commit 4ffead7

File tree

6 files changed

+53
-5
lines changed

6 files changed

+53
-5
lines changed

src/dsstats.api/Controllers/UploadController.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ public async Task<ActionResult> ImportReplays8([FromBody] UploadDto uploadDto)
3434
return BadRequest();
3535
}
3636

37+
[HttpPost]
38+
[RequestSizeLimit(1024000000)]
39+
[Route("ImportPwaReplays")]
40+
public async Task<ActionResult> ImportPwaReplays([FromBody] UploadDto uploadDto)
41+
{
42+
var success = await uploadService.Upload(uploadDto);
43+
if (success)
44+
{
45+
return Ok();
46+
}
47+
return BadRequest();
48+
}
49+
3750
[HttpPost]
3851
[RequestSizeLimit(15728640)]
3952
[Route("uploadreplays/{guid}")]

src/dsstats.api/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"https://dsstats-dev.pax77.org",
3636
"https://localhost:7257",
3737
"https://localhost:7227",
38-
"http://localhost:5123")
38+
"http://localhost:5123",
39+
"https://localhost:7039")
3940
.AllowAnyHeader()
4041
.AllowAnyMethod();
4142
});

src/dsstats.db8/AutoMapper/AutoMapperProfile.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ public AutoMapperProfile()
1010
CreateMap<Player, PlayerDto>(MemberList.Destination);
1111
CreateMap<PlayerDto, Player>(MemberList.Source);
1212

13-
CreateMap<Replay, ReplayDto>(MemberList.Destination);
14-
CreateMap<ReplayDto, Replay>(MemberList.Source);
13+
CreateMap<Replay, ReplayDto>(MemberList.Destination)
14+
.ForMember(x => x.CompatHash, opt => opt.Ignore());
15+
CreateMap<ReplayDto, Replay>(MemberList.Source)
16+
.ForSourceMember(x => x.CompatHash, opt => opt.DoNotValidate());
1517

1618
CreateMap<ReplayPlayer, ReplayPlayerDto>(MemberList.Destination)
1719
.ForMember(x => x.MmrChange, opt => opt.Ignore());

src/dsstats.db8services/Import/ImportService.Import.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using dsstats.shared;
55
using Microsoft.Extensions.DependencyInjection;
66
using System.Security.Cryptography;
7+
using System.Text;
78

89
namespace dsstats.db8services.Import;
910

@@ -35,8 +36,14 @@ public async Task<ImportResult> Import(List<ReplayDto> replayDtos, List<PlayerId
3536

3637
for (int i = 0; i < replayDtos.Count; i++)
3738
{
38-
AdjustReplay(replayDtos[i]);
39-
foreach (var rp in replayDtos[i].ReplayPlayers)
39+
var replay = replayDtos[i];
40+
AdjustReplay(replay);
41+
if (!string.IsNullOrEmpty(replay.CompatHash))
42+
{
43+
var hash = MD5.HashData(Encoding.UTF8.GetBytes(replay.CompatHash));
44+
replay.ReplayHash = Convert.ToHexString(hash).ToLowerInvariant();
45+
}
46+
foreach (var rp in replay.ReplayPlayers)
4047
{
4148
var playerId = new PlayerId(rp.Player.ToonId, rp.Player.RealmId, rp.Player.RegionId);
4249
if (!playerInfos.ContainsKey(playerId))

src/dsstats.shared/ReplayDto.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public record ReplayDto
3030
public int Maxleaver { get; init; }
3131
public byte Playercount { get; init; }
3232
public string ReplayHash { get; set; } = "";
33+
public string? CompatHash { get; set; }
3334
public bool DefaultFilter { get; set; }
3435
public int Views { get; init; }
3536
public int Downloads { get; init; }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dsstats.shared", "dsstats.shared.csproj", "{ABE304FB-4058-DB15-59A0-5EEC4719A12A}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{ABE304FB-4058-DB15-59A0-5EEC4719A12A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{ABE304FB-4058-DB15-59A0-5EEC4719A12A}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{ABE304FB-4058-DB15-59A0-5EEC4719A12A}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{ABE304FB-4058-DB15-59A0-5EEC4719A12A}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {C16CAF09-8285-4A18-B2CB-F99C945AF746}
23+
EndGlobalSection
24+
EndGlobal

0 commit comments

Comments
 (0)