Skip to content

Commit

Permalink
fix: #tno-2269 - fixed reporting service (#1465)
Browse files Browse the repository at this point in the history
- code to include aggregations on section was missing
- moved converter to shared library
  • Loading branch information
kylgarmor authored Jan 26, 2024
1 parent 181ed64 commit 9fba7b1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions api/net/Areas/Helpers/ReportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using TNO.TemplateEngine.Models;
using TNO.TemplateEngine.Models.Charts;
using TNO.TemplateEngine.Models.Reports;
using TNO.TemplateEngine.Converters;

namespace TNO.API.Helpers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace TNO.API.Helpers;
namespace TNO.TemplateEngine.Converters;

/// <summary>
/// Extension methods to convert between Elastic models and Report models
/// </summary>
public static class SearchAggregationHelper
{
/// <summary>
/// <summary>
/// Convert from one model to another
/// </summary>
/// <param name="model"></param>
Expand Down
1 change: 1 addition & 0 deletions libs/net/template/TNO.TemplateEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\elastic\TNO.Elastic.csproj" />
<ProjectReference Include="..\core\TNO.Core.csproj" />
<ProjectReference Include="..\models\TNO.Models.csproj" />
<ProjectReference Include="..\entities\TNO.Entities.csproj" />
Expand Down
9 changes: 9 additions & 0 deletions services/net/reporting/ReportingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using TNO.TemplateEngine;
using TNO.TemplateEngine.Models;
using TNO.TemplateEngine.Models.Reports;
using TNO.TemplateEngine.Converters;

namespace TNO.Services.Reporting;

Expand Down Expand Up @@ -360,6 +361,14 @@ private async Task GenerateReportAsync(ReportRequestModel request, API.Areas.Ser
{
var sortOrder = 0;
section.Content = this.ReportEngine.OrderBySectionField(results.Hits.Hits.Select(h => new ContentModel(h.Source, sortOrder++)).OrderBy(c => c.SortOrder).ToArray(), section.Settings.SortBy);
if (results.Aggregations != null)
{
section.Aggregations = new Dictionary<string, TNO.TemplateEngine.Models.Reports.AggregationRootModel>();
foreach (var aggregation in results.Aggregations)
{
section.Aggregations.Add(aggregation.Key, aggregation.Value.Convert());
}
}
}
return section;
});
Expand Down

0 comments on commit 9fba7b1

Please sign in to comment.