Skip to content

Commit

Permalink
Remove unnecessary backend code
Browse files Browse the repository at this point in the history
  • Loading branch information
simpat-adam committed Jan 9, 2025
1 parent 52bcadf commit db73cd0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ await _sqlAction.InsertAlias(
}

_logger.LogDebug("Upsert success as insert - {TraceId}", upsertRequest.TraceId.Value);
return new UpsertResult.InsertSuccess(
upsertRequest.DocumentUuid,
new Etag(upsertRequest.EdfiDoc["_etag"]?.ToString() ?? "")
);
return new UpsertResult.InsertSuccess(upsertRequest.DocumentUuid);
}

public async Task<UpsertResult> AsUpdate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public record UpsertResult
/// A successful upsert request that took the form of an insert
/// </summary>
/// <param name="NewDocumentUuid">The DocumentUuid of the new document</param>
/// <param name="Etag">The Etag of the new document</param>
public record InsertSuccess(DocumentUuid NewDocumentUuid, Etag Etag) : UpsertResult();
public record InsertSuccess(DocumentUuid NewDocumentUuid) : UpsertResult();

/// <summary>
/// A successful upsert request that took the form of an update
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System.Text.Json.Nodes;
using EdFi.DataManagementService.Core.ApiSchema;
using EdFi.DataManagementService.Core.Backend;
using EdFi.DataManagementService.Core.External.Backend;
using EdFi.DataManagementService.Core.External.Interface;
Expand Down Expand Up @@ -58,7 +57,7 @@ public void It_has_the_correct_response()
{
context.FrontendResponse.StatusCode.Should().Be(200);
context.FrontendResponse.Body.Should().BeNull();
context.FrontendResponse.Headers.Count.Should().Be(0);
context.FrontendResponse.Headers.Count.Should().Be(1);
context.FrontendResponse.LocationHeaderPath.Should().NotBeNullOrEmpty();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<UpsertResult> UpsertDocument(IUpsertRequest upsertRequest)
upsertRequest.TraceId
);
return await Task.FromResult<UpsertResult>(
new UpsertResult.InsertSuccess(upsertRequest.DocumentUuid, new Etag(""))
new UpsertResult.InsertSuccess(upsertRequest.DocumentUuid)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ internal record UpsertRequest(
IUpdateCascadeHandler UpdateCascadeHandler
)
: UpdateRequest(ResourceInfo, DocumentInfo, EdfiDoc, TraceId, DocumentUuid, UpdateCascadeHandler),
IUpsertRequest
{
}
IUpsertRequest;
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public async Task Execute(PipelineContext context, Func<Task> next)
context.FrontendResponse = upsertResult switch
{
InsertSuccess insertSuccess => new FrontendResponse(
StatusCode: 201,
Body: null,
Headers: new Dictionary<string, string>() { { "etag", insertSuccess.Etag.Value } },
StatusCode: 201,
Body: null,
Headers: new Dictionary<string, string>() { { "etag", context.ParsedBody["_etag"]?.ToString() ?? "" } },
LocationHeaderPath: PathComponents.ToResourcePath(
context.PathComponents,
insertSuccess.NewDocumentUuid
Expand All @@ -70,7 +70,7 @@ public async Task Execute(PipelineContext context, Func<Task> next)
UpdateSuccess updateSuccess => new(
StatusCode: 200,
Body: null,
Headers: [],
Headers: new Dictionary<string, string>() { { "etag", context.ParsedBody["_etag"]?.ToString() ?? "" } },
LocationHeaderPath: PathComponents.ToResourcePath(
context.PathComponents,
updateSuccess.ExistingDocumentUuid
Expand Down

0 comments on commit db73cd0

Please sign in to comment.