Skip to content

Commit

Permalink
Order A+ carbon rating correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick Butterfield committed Apr 25, 2024
1 parent 431b99e commit 030d92c
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Diagnostics;
using System.Text.Json;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.Operations;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
Expand Down Expand Up @@ -39,7 +41,7 @@ public async Task<IActionResult> GetOverviewData(int pageNumber = 1, int pageSiz
switch (orderBy)
{
case nameof(PageMetric.CarbonRating):
filter = x => x.CarbonRating;
filter = x => GetCarbonRatingOrder(x.CarbonRating);
break;
case nameof(PageMetric.RequestDate):
filter = x => x.RequestDate;
Expand Down Expand Up @@ -126,5 +128,28 @@ public async Task<IActionResult> SavePageData([FromQuery] int pageId, [FromBody]
await _pageMetricService.AddPageMetric(pageMetric);
return Ok(true);
}

private int GetCarbonRatingOrder(string carbonRating)
{
switch (carbonRating)
{
case "A+":
return 1;
case "A":
return 2;
case "B":
return 3;
case "C":
return 4;
case "D":
return 5;
case "E":
return 6;
case "F":
return 7;
default:
return 7;
}
}
}
}

0 comments on commit 030d92c

Please sign in to comment.