From d107cc8e8b32427d4c402670153331b7613d3119 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Fri, 3 Jul 2020 09:42:44 -0400 Subject: [PATCH] Working query filter for co2s --- WebCms/Utility/QueryFilter.cs | 17 ++++---- .../LeafInputDataViewModels.cshtml | 39 +++++++++++++------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/WebCms/Utility/QueryFilter.cs b/WebCms/Utility/QueryFilter.cs index fb2599a..31b25bf 100644 --- a/WebCms/Utility/QueryFilter.cs +++ b/WebCms/Utility/QueryFilter.cs @@ -72,18 +72,21 @@ namespace LeafWeb.WebCms.Utility lid.Site.Longitude <= longitude + range) select li; } - + + // co2s if (!string.IsNullOrEmpty(query.co2s)) { - var co2s = double.Parse(query.co2s); + var p = double.Parse(query.co2s); resultItems = from li in resultItems - where co2s >= - li.LeafInputData.Max(lid => - lid.Data.Max(d => d.CO2S) - - lid.Data.Min(d => d.CO2S) - ) + where + // maximum range inside LeafInputFiles + li.LeafInputData.Max(lid => + // range of LeafInputData + lid.Data.Max(d => d.CO2S) + - lid.Data.Min(d => d.CO2S)) + >= p select li; } diff --git a/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml b/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml index 32db1f8..9e11507 100644 --- a/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml +++ b/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml @@ -11,17 +11,34 @@ @RendDistinctValues("Latitude [°]", Model.Select(m => m.Site.Latitude?.ToString())) @RendDistinctValues("Longitude [°]", Model.Select(m => m.Site.Longitude?.ToString())) @RendDistinctValues("Elevation [m]", Model.Select(m => m.Site.Elevation?.ToString())) -@RendDistinctValues("CO2S", - Model.Select(m => - m.SiteName + ": " - + string.Join(", ", +@RendDistinctValues("CO2S", + Model.Select(m => + m.SiteName + " (" + m.Id + "): " + + string.Join(", ", m.Data?.Select(d => d.CO2S?.ToString()) ) - ) + + ), "
" ) -@RendDistinctValues("CO2S Min", Model.Select(m => m.Data?.Min(d => d.CO2S).ToString())) -@RendDistinctValues("CO2S Average", Model.Select(m => m.Data?.Average(d => d.CO2S).ToString())) -@RendDistinctValues("CO2S Max", Model.Select(m => m.Data?.Max(d => d.CO2S).ToString())) +@RendDistinctValues("CO2S Min", Model.Select(m => + m.SiteName + " (" + m.Id + "): " + + m.Data?.Min(d => d.CO2S).ToString()), "
") +@RendDistinctValues("CO2S Average", Model.Select(m => + m.SiteName + " (" + m.Id + "): " + + m.Data?.Average(d => d.CO2S).ToString()), "
") +@RendDistinctValues("CO2S Max", Model.Select(m => + m.SiteName + " (" + m.Id + "): " + + m.Data?.Max(d => d.CO2S).ToString()), "
") +@RendDistinctValues("CO2S Range", Model.Select(m => + m.SiteName + " (" + m.Id + "): " + + (m.Data?.Max(d => d.CO2S) + - m.Data?.Min(d => d.CO2S))), "
") +@RendValue("CO2S Max Range", Model.Max(m => + m.Data?.Max(d => d.CO2S) + - m.Data?.Min(d => d.CO2S))?.ToString()) +@RendValue("CO2S Min Range", Model.Min(m => + m.Data?.Max(d => d.CO2S) + - m.Data?.Min(d => d.CO2S))?.ToString()) @helper RendValue(string label, string value) @@ -31,13 +48,13 @@ @Html.Raw(label)
- @value + @Html.Raw(@value)
} -@helper RendDistinctValues(string label, IEnumerable values) +@helper RendDistinctValues(string label, IEnumerable values, string seperator = ", ") { - var value = string.Join(", ", values.Distinct()); + var value = string.Join(seperator, values.Distinct()); @RendValue(label, value) } \ No newline at end of file