Skip to content

Commit

Permalink
Use height instead of flow (wrong values for diagramm)
Browse files Browse the repository at this point in the history
  • Loading branch information
bauerjakob committed Jan 8, 2024
1 parent 5c1a935 commit 1c86c59
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
context: ./innai
dockerfile: Dockerfile
ports:
- 8000:80-k00
- 8000:8000
networks:
- backend

Expand Down
2 changes: 1 addition & 1 deletion server/InnAi.Server/InnAi.Server/Clients/InnLevelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task<double[]> GetAsync(DateTime dateTime, int count)
{
var station = _options.Stations[i];

var response = await _client.GetAsync($"/api/station/1.0/{(station.Contains("at") ? "height" : "flow")}/{station}/history?granularity=hour&loadEndDate={dateStringEnd}&loadStartDate={dateStringFrom}");
var response = await _client.GetAsync($"/api/station/1.0/height/{station}/history?granularity=hour&loadEndDate={dateStringEnd}&loadStartDate={dateStringFrom}");

var content = await response.Content.ReadAsStreamAsync();
var json = await JsonDocument.ParseAsync(content);
Expand Down
50 changes: 39 additions & 11 deletions server/InnAi.Server/InnAi.Server/Controllers/InnAiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,47 @@ public async Task<ActionResult<AiModelDto[]>> GetAiModelsAsync()
}
}

[HttpPost("model")]
public async Task<IActionResult> CretaeModelAsync(CreateModelRequestDto dto)
// [HttpPost("model")]
// public async Task<IActionResult> CretaeModelAsync(CreateModelRequestDto dto)
// {
// try
// {
// await _innAiService.CreateAiModelAsync(dto);
// return Created();
// }
// catch (Exception e)
// {
// _logger.LogError(e, string.Empty);
// return StatusCode(StatusCodes.Status500InternalServerError);
// }
//
// }

[HttpGet("evaluate/month/{modelId}")]
public async Task<ActionResult<EvaluateMonthDto>> EvaluateMonthAsync(Guid modelId, int year, int month)
{
try
{
await _innAiService.CreateAiModelAsync(dto);
return Created();
}
catch (Exception e)
var dateTime = new DateTime(year, month, 1);

var days = DateTime.DaysInMonth(year, month);

List<EvaluateDayDto> daysEvaluated = new();

for (var i = 0; i < days; i++)
{
_logger.LogError(e, string.Empty);
return StatusCode(StatusCodes.Status500InternalServerError);
var predictionResult = await _innAiService.PredictHistoryAsync(dateTime, modelId);

var evaluation = new EvaluateDayDto(dateTime, predictionResult.AverageDeviation);
daysEvaluated.Add(evaluation);

dateTime += TimeSpan.FromDays(1);
}


var sumDeviation = daysEvaluated.Sum(x => x.averageDeviation);
var averageDeviation = sumDeviation / daysEvaluated.Count;

return Ok(new EvaluateMonthDto(daysEvaluated.ToArray(), sumDeviation, averageDeviation));

}


}
6 changes: 6 additions & 0 deletions server/InnAi.Server/InnAi.Server/Dtos/EvaluateMonthDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System.Runtime.InteropServices.JavaScript;

namespace InnAi.Server.Dtos;

public record EvaluateMonthDto(EvaluateDayDto[] days, double sumDeviation, double averageDeviatoin);
public record EvaluateDayDto(DateTime day, double averageDeviation);

0 comments on commit 1c86c59

Please sign in to comment.