Skip to content

Commit

Permalink
Merge pull request #437 from DFE-Digital/free-school-meals-data-update
Browse files Browse the repository at this point in the history
Updated hardcoded freeschool meals data to 23/24
  • Loading branch information
dneed-nimble authored Aug 9, 2024
2 parents 92e4fae + 52df3d3 commit e6da463
Show file tree
Hide file tree
Showing 9 changed files with 800 additions and 1,381 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Implemented service and repository design patterns for retrieving data from AcademiesDb.
- Data source information cached to increase performance of all Trust pages.
- Trust summary information (UID, name, type and number of academies) cached to improve performance of all Trust pages.
- Updated hardcoded free schools meals data to be updated to 23/24, resolving a bug relating to new Local Authorities within that data

## [Release-2][release-2] (production-2024-07-29.2601)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
using System.Diagnostics.CodeAnalysis;
using DfE.FindInformationAcademiesTrusts.Data.Enums;
using DfE.FindInformationAcademiesTrusts.Data.Repositories.Models;

namespace DfE.FindInformationAcademiesTrusts.Data.Hardcoded;

[ExcludeFromCodeCoverage]
public class FreeSchoolMealsAverageProvider : IFreeSchoolMealsAverageProvider
{
private const int NationalKey = -1;

public double GetLaAverage(Academy academy)
{
var key = GetPhaseTypeKey(academy);
return FreeSchoolMealsData.Averages2022To23[academy.OldLaCode].PercentOfPupilsByPhase[key];
return FreeSchoolMealsData.Averages2023To24[academy.OldLaCode].PercentOfPupilsByPhase[key];
}

public double GetNationalAverage(Academy academy)
{
var key = GetPhaseTypeKey(academy);
return FreeSchoolMealsData.Averages2022To23[NationalKey].PercentOfPupilsByPhase[key];
return FreeSchoolMealsData.Averages2023To24[NationalKey].PercentOfPupilsByPhase[key];
}

public DataSource GetFreeSchoolMealsUpdated()
Expand Down
2,121 changes: 782 additions & 1,339 deletions DfE.FindInformationAcademiesTrusts.Data.Hardcoded/FreeSchoolMealsData.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<tr class="govuk-table__row">
<th scope="col" class="govuk-body govuk-table__header" aria-sort="ascending">School name</th>
<th scope="col" class="govuk-body govuk-table__header" aria-sort="none">Pupils eligible for free school meals</th>
<th scope="col" class="govuk-body govuk-table__header" aria-sort="none">Local authority average 2022/23</th>
<th scope="col" class="govuk-body govuk-table__header" aria-sort="none">National average 2022/23</th>
<th scope="col" class="govuk-body govuk-table__header" aria-sort="none">Local authority average 2023/24</th>
<th scope="col" class="govuk-body govuk-table__header" aria-sort="none">National average 2023/24</th>
</tr>
</thead>
<tbody class="govuk-table__body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override async Task<IActionResult> OnGetAsync()
DataSources.Add(new DataSourceListEntry(await DataSourceService.GetAsync(Source.ExploreEducationStatistics),
new[]
{
"Local authority average 2022/23", "National average 2022/23"
"Local authority average 2023/24", "National average 2023/24"
}));

return pageResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe("Testing a multi-academy trust", () => {
.then((row) => {
row
.hasPupilsEligible("5.0%")
.hasLocalAuthorityAverage("29.2%")
.hasNationalAverage("24.0%");
.hasLocalAuthorityAverage("29.4%")
.hasNationalAverage("24.9%");
});
}

Expand Down Expand Up @@ -156,8 +156,8 @@ describe("Testing a multi-academy trust", () => {
.then((row) => {
row
.hasPupilsEligible("29.0%")
.hasLocalAuthorityAverage("26.3%")
.hasNationalAverage("24.0%");
.hasLocalAuthorityAverage("27.6%")
.hasNationalAverage("24.9%");
});
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ describe("Searching for a trust and checking information", () => {
.hasName(academyName)
.hasUrn(academyUrn)
.hasPupilsEligible("20.0%")
.hasLocalAuthorityAverage("27.8%")
.hasNationalAverage("22.7%");
.hasLocalAuthorityAverage("29.3%")
.hasNationalAverage("25.6%");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,6 @@ public class FreeSchoolMealsAverageProviderTests
{
private readonly FreeSchoolMealsAverageProvider _sut = new();

[Theory]
[InlineData(334, "Secondary", "Pupil Referral Unit", 63.52941176F)]
[InlineData(372, "Primary", "Community School", 26.26287001F)]
[InlineData(929, "16 Plus", "Academy Converter", 20.62056176F)]
[InlineData(931, "All-through", "Free Schools Special", 38.25095057F)]
public void GetLaAverage_should_return_percentage_from_hardcoded_data(int laCode, string phaseOfEducation,
string establishmentType, double expected)
{
var dummyAcademy = GetDummyAcademy(111, laCode: laCode, phaseOfEducation: phaseOfEducation,
typeOfEstablishment: establishmentType);
var result = _sut.GetLaAverage(dummyAcademy);
result.Should().BeApproximately(expected, 0.01F);
}

[Theory]
[InlineData("Secondary", "Pupil Referral Unit", 57.78940186F)]
[InlineData("Primary", "Community School", 23.99569177F)]
[InlineData("16 Plus", "Academy Converter", 22.69174097F)]
[InlineData("All-through", "Free Schools Special", 45.98689461F)]
public void GetNationalAverage_should_return_national_percentage_from_hardcoded_data(string phaseOfEducation,
string establishmentType, double expected)
{
var dummyAcademy = GetDummyAcademy(111, phaseOfEducation: phaseOfEducation,
typeOfEstablishment: establishmentType);
var result = _sut.GetNationalAverage(dummyAcademy);
result.Should().BeApproximately(expected, 0.01F);
}

[Theory]
[InlineData("Secondary", "Pupil Referral Unit", ExploreEducationStatisticsPhaseType
.StateFundedApSchool)]
Expand Down Expand Up @@ -84,7 +56,7 @@ public void GetKey_should_throw_exception_if_values_are_not_in_data()
public void GetFsmUpdated_should_return_data_source()
{
var result = _sut.GetFreeSchoolMealsUpdated();
result.Should().Be(new DataSource(Source.ExploreEducationStatistics, new DateTime(2023, 10, 2),
result.Should().Be(new DataSource(Source.ExploreEducationStatistics, new DateTime(2024, 8, 6),
UpdateFrequency.Annually));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public FreeSchoolMealsModelTests()

_sut = new FreeSchoolMealsModel(_mockTrustProvider.Object, _mockFreeSchoolMealsAverageProvider.Object,
_mockDataSourceService.Object, new MockLogger<FreeSchoolMealsModel>().Object,
_mockTrustRepository.Object) { Uid = "1234" };
_mockTrustRepository.Object)
{ Uid = "1234" };
}

[Fact]
Expand Down Expand Up @@ -91,7 +92,7 @@ public async Task OnGetAsync_sets_correct_data_source_list()
});
_sut.DataSources[1].Fields.Should().Contain(new[]
{
"Local authority average 2022/23", "National average 2022/23"
"Local authority average 2023/24", "National average 2023/24"
});
}
}

0 comments on commit e6da463

Please sign in to comment.