Skip to content

Commit

Permalink
Change how we send job params (#32)
Browse files Browse the repository at this point in the history
* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update DatabricksJobsHelper.cs

* Update SettlementReportsController.cs

* Update SettlementReportsController.cs

* Update SettlementReportsController.cs
  • Loading branch information
FirestarJes authored Sep 24, 2024
1 parent d77a2d0 commit a68e101
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,32 @@ private RunParameters CreateParameters(SettlementReportRequestDto request, Marke
{
var gridAreas = $"{{{string.Join(", ", request.Filter.GridAreas.Select(c => $"\"{c.Key}\": \"{(c.Value is null ? string.Empty : c.Value?.Id)}\""))}}}";

var jobParameters = new List<string>
var jobParameters = new Dictionary<string, string>()
{
$"--report-id={reportId.Id}",
$"--calculation-type={CalculationTypeMapper.ToDeltaTableValue(request.Filter.CalculationType)}",
$"--calculation-id-by-grid-area={gridAreas}",
$"--period-start={request.Filter.PeriodStart.ToInstant()}",
$"--period-end={request.Filter.PeriodEnd.ToInstant()}",
$"--market-role={MapMarketRole(marketRole)}",
{ "report-id", reportId.Id },
{ "calculation-type", CalculationTypeMapper.ToDeltaTableValue(request.Filter.CalculationType) },
{ "calculation-id-by-grid-area", gridAreas },
{ "period-start", request.Filter.PeriodStart.ToInstant().ToString() },
{ "period-end", request.Filter.PeriodEnd.ToInstant().ToString() },
{ "market-role", MapMarketRole(marketRole) },
};

if (request.Filter.EnergySupplier != null)
{
jobParameters.Add($"--energy-supplier-id={request.Filter.EnergySupplier}");
jobParameters.Add("energy-supplier-id", request.Filter.EnergySupplier);
}

if (request.SplitReportPerGridArea)
{
jobParameters.Add("--split-report-by-grid-area");
jobParameters.Add("split-report-by-grid-area", request.SplitReportPerGridArea.ToString());
}

if (request.PreventLargeTextFiles)
{
jobParameters.Add("--prevent-large-text-files");
jobParameters.Add("prevent-large-text-files", request.PreventLargeTextFiles.ToString());
}

return RunParameters.CreatePythonParams(jobParameters);
return RunParameters.CreateJobParams(jobParameters);
}

private static string MapMarketRole(MarketRole marketRole)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ public async Task<IEnumerable<RequestedSettlementReportDto>> ListSettlementRepor
return await _listSettlementReportJobsHandler.HandleAsync(_userContext.CurrentUser.Actor.ActorId).ConfigureAwait(false);
}

[HttpGet]
[HttpPost]
[Route("download")]
[Authorize]
[Produces("application/octet-stream")]
[ProducesResponseType(typeof(FileResult), StatusCodes.Status200OK)]
[EnableRevision(activityName: "DownloadSettlementReportAPI", entityType: typeof(RequestedSettlementReportDto))]
public async Task<ActionResult> DownloadFileAsync(SettlementReportRequestId requestId)
public async Task<ActionResult> DownloadFileAsync([FromBody]SettlementReportRequestId requestId)
{
try
{
Expand All @@ -140,7 +140,7 @@ await _downloadHandler
_userContext.CurrentUser.MultiTenancy)
.ConfigureAwait(false);

return File(stream.GetBuffer(), MediaTypeNames.Application.Zip);
return File(stream.GetBuffer(), MediaTypeNames.Application.Octet);
}
catch (Exception ex) when (ex is InvalidOperationException or RequestFailedException)
{
Expand Down

0 comments on commit a68e101

Please sign in to comment.