Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register IInstanceAndEventsRepository #572

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Storage/Controllers/ProcessController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/// </summary>
[Route("storage/api/v1/instances/{instanceOwnerPartyId:int}/{instanceGuid:guid}/process")]
[ApiController]
public class ProcessController : ControllerBase

Check warning on line 28 in src/Storage/Controllers/ProcessController.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

This controller has multiple responsibilities and could be split into 2 smaller controllers. (https://rules.sonarsource.com/csharp/RSPEC-6960)
{
private readonly IInstanceRepository _instanceRepository;
private readonly IInstanceEventRepository _instanceEventRepository;
Expand Down Expand Up @@ -132,6 +132,15 @@
return NotFound();
}

foreach (InstanceEvent instanceEvent in processStateUpdate.Events)
{
if (string.IsNullOrWhiteSpace(instanceEvent.InstanceId))
{
instanceEvent.InstanceId = $"{instanceOwnerPartyId}/{instanceGuid}";
}

Check failure on line 140 in src/Storage/Controllers/ProcessController.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check failure on line 140 in src/Storage/Controllers/ProcessController.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

Check failure on line 140 in src/Storage/Controllers/ProcessController.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

Check failure on line 140 in src/Storage/Controllers/ProcessController.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

instanceEvent.Created = instanceEvent.Created?.ToUniversalTime() ?? DateTime.UtcNow;
}

ProcessState processState = processStateUpdate.State;

var (action, taskId) = ActionMapping(processState, existingInstance);
Expand Down Expand Up @@ -234,7 +243,7 @@
existingInstance.LastChanged = DateTime.UtcNow;
}

private (string Action, string TaskId) ActionMapping(ProcessState processState, Instance existingInstance)

Check warning on line 246 in src/Storage/Controllers/ProcessController.cs

View workflow job for this annotation

GitHub Actions / Build, test & analyze

Make 'ActionMapping' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
string taskId = null;
string altinnTaskType = existingInstance.Process?.CurrentTask?.AltinnTaskType;
Expand Down
1 change: 1 addition & 0 deletions src/Storage/Repository/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static IServiceCollection AddRepositoriesPostgreSQL(this IServiceCollecti
.AddSingleton<IDataRepository, PgDataRepository>()
.AddSingleton<IInstanceEventRepository, PgInstanceEventRepository>()
.AddSingleton<IInstanceRepository, PgInstanceRepository>()
.AddSingleton<IInstanceAndEventsRepository, PgInstanceAndEventsRepository>()
.AddSingleton<IBlobRepository, BlobRepository>()
.AddSingleton<IA2Repository, PgA2Repository>()
.AddNpgsqlDataSource(connectionString, builder => builder.EnableParameterLogging(logParameters).EnableDynamicJson());
Expand Down
Loading