Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1171 from cocoa-mhlw/feature/save_partition_key_i…
Browse files Browse the repository at this point in the history
…n_eventlog_api

Feature/save partition key in eventlog api
  • Loading branch information
cocoa-dev006 authored Oct 17, 2022
2 parents adfc824 + 1f6320e commit acc6b83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Covid19Radar.Api/DataAccess/CosmosEventLogRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ ILogger<CosmosEventLogRepository> logger

public async Task UpsertAsync(EventLogModel eventLog)
{
ItemResponse<EventLogModel> recordAdded = await _db.EventLog.UpsertItemAsync(eventLog);
PartitionKey? pk = null;
if(eventLog.PartitionKey is not null)
{
pk = new PartitionKey(eventLog.PartitionKey);
}
ItemResponse<EventLogModel> recordAdded = await _db.EventLog.UpsertItemAsync(eventLog, pk);
_logger.LogInformation($"{nameof(UpsertAsync)} RequestCharge:{recordAdded.RequestCharge}");
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Covid19Radar.Api/V1EventLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public async Task<IActionResult> RunAsync(
)
{
id = id,
PartitionKey = id,
Created = timestamp,
};
await _eventLogRepository.UpsertAsync(eventLogModel);
Expand Down

0 comments on commit acc6b83

Please sign in to comment.