Skip to content

Commit

Permalink
Update identifier and improved upsert detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Sep 11, 2024
1 parent 771dac8 commit 994d67e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Media/Jobs/UploadMediaJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ public async Task ExecuteAsync(int recordId, string identifier, string ghostData
}
}

public static void Schedule(IJobScheduler jobScheduler, int recordId, string ghostData, string screenshotData)
public static void Schedule(IJobScheduler jobScheduler,
int userId,
int recordId,
string ghostData,
string screenshotData)
{
jobScheduler.Enqueue<UploadMediaJob>(
recordId,
recordId.ToString() + "-" + Guid.NewGuid(),
$"{userId}-{recordId}-{Guid.NewGuid()}",
ghostData,
screenshotData);
}
Expand Down
4 changes: 2 additions & 2 deletions Media/MediaService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<Result<string>> UploadGhost(int recordId, string b64, string i
}

RecordMedia recordMedia = _repository.Upsert(
recordId,
media => media.IdRecord == recordId,
() => new RecordMedia
{
IdRecord = recordId,
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task<Result<string>> UploadScreenshot(int recordId, string b64, str
}

RecordMedia recordMedia = _repository.Upsert(
recordId,
media => media.IdRecord == recordId,
() => new RecordMedia
{
IdRecord = recordId,
Expand Down
2 changes: 1 addition & 1 deletion Records/RecordsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public Result Submit(ulong steamId, RecordResource resource)
DateCreated = now,
});

UploadMediaJob.Schedule(_jobScheduler, record.Id, resource.GhostData, resource.ScreenshotData);
UploadMediaJob.Schedule(_jobScheduler, user.Id, record.Id, resource.GhostData, resource.ScreenshotData);
ProcessPersonalBestJob.Schedule(_jobScheduler, record.Id, record.IdUser, record.IdLevel);
ProcessWorldRecordJob.Schedule(_jobScheduler, record.Id, record.IdLevel);
return Result.Ok();
Expand Down

0 comments on commit 994d67e

Please sign in to comment.