Skip to content

Add similar school datamap and setup for primary schools - #283

Merged
vipinsamreddy merged 29 commits into
mainfrom
feature/similar-schools-primary
Jul 23, 2026
Merged

Add similar school datamap and setup for primary schools#283
vipinsamreddy merged 29 commits into
mainfrom
feature/similar-schools-primary

Conversation

@vipinsamreddy

@vipinsamreddy vipinsamreddy commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Description

Summary
Implements the "View similar schools" page for primary schools (feature-flagged behind EnablePrimarySchools), mirroring the existing secondary schools feature: results list, filters, sort, pagination, and map view. Includes the full "Sort by" measure mapping and a round of alignment against the codebase's established use-case standard.

What's included
Core feature

List/filter/sort/paginate/map view for primary similar schools, following the same UX pattern as secondary.
Sort by — all 6 required measures wired up (Meeting/Achieving-higher standard in RWM and GPS, average scaled score in reading/maths), each using the latest year's data, correct 0dp/1dp formatting, and alphabetical tie-break for equal or missing scores.
Bug fixes

Address on the results list no longer renders the school's own name where the street should be (a GIAS data quirk where Address3 often duplicates the establishment name) — now built from Street/Town/Postcode, matching secondary.
Removed the extra "local authority" line from each result row to match secondary's layout.
Schools with no similar-schools group no longer 404 to the generic error page — they now show "There are no similar schools available for this school." (same as secondary), instead of the use case throwing NotFoundException on a missing (but valid) characteristics row.
Standards alignment (post-review)

Renamed FindPrimarySimilarSchools → FindPrimarySimilarSchoolsUseCase, matching the {Verb}{Noun}UseCase convention used by GetSchoolInfoUseCase/GetSchoolKs2PerformanceMeasuresUseCase.
Extracted PrimarySimilarSchoolsDataProvider so the use case's Execute is a thin orchestrator (fetch → filter → sort → paginate), mirroring the PrimarySimilarSchoolsPerformanceDataProvider pattern used by KS2 measures.
Removed duplication: deleted an unused/dead data-provider stub, extracted a shared SimilarSchoolsDecimalParsing helper, de-duplicated the row-mapping and query-filter-extraction logic in the ViewModel/controller, moved a ~70-line inline filter script into AssetSrc/js/similar-schools-filter.js.

Related Trello Ticket

https://trello.com/c/Id9I1aSV/874-ps40-view-similar-schools-page-for-primary-schools-list-map-view
https://trello.com/c/X0Zh5R8u/855-ps42-view-similar-schools-page-sort-by-functionality
https://trello.com/c/tI4YJ5fL/852-ps41-view-similar-schools-page-filters

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • Tested on [Environment: Dev/Staging/Local]

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have verified accessibility requirements are met

Screenshots (if applicable)

image

# Conflicts:
#	SAPSec.Data/Repositories/ISimilarSchoolsPrimaryRepository.cs
#	SAPSec.Infrastructure/Json/JsonSimilarSchoolsPrimaryRepository.cs
#	SAPSec.Infrastructure/Json/ServiceCollectionExtensions.cs
#	SAPSec.Infrastructure/Postgres/PostgresSimilarSchoolsPrimaryRepository.cs
#	Tests/SAPSec.Test.Common/InMemory/InMemorySimilarSchoolsPrimaryRepository.cs
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review app for PR 283 was deleted

Comment thread SAPSec.Core/Features/SimilarSchools/SimilarSchoolsDecimalParsing.cs Outdated
grouplinks_edubaseallacademiesandfreeYYYYmmDD
secondary-email-addresses-12-01-2026
2026_07_03_neighbours_list_primary
2026_07_03_matched_primary_schools_data No newline at end of file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we don't include secondary similar schools raw tables in this list?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this are newly added list just want them to be build as part of the list

double? Latitude,
double? Longitude,
string SortMetricName,
DataWithAvailability<string> SortMetricDisplayValue,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In secondary similar schools this is represented using SortOptionValue<T> - any reason why this is different?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it

? parsed
: 0;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems generic and not related to similar schools - could this be pulled out into a generic helper class?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it

var characteristics = SimilarSchoolsPrimaryValues.FromData(
await similarSchoolsRepository.GetValuesByUrnsAsync(urns))
.ToDictionary(values => values.Urn, StringComparer.Ordinal);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we need the similar school values here, they don't seem to be applicable to getting a list of similar schools

Comment thread SAPSec.Infrastructure/Postgres/PostgresDependenciesExtensions.cs
}

return grouped;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a lot of this is duplicated across secondary similar schools view models - could this be factored out at all?

</div>
</div>
</form>
</div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These views are almost identical to the secondary similar schools views - it looks like the only difference between them is the similar schools URL. Can we look at sharing these views across both primary and secondary and passing in the URL as a parameter?

@github-actions

Copy link
Copy Markdown

Code Coverage Report: Only Changed Files listed

Package Coverage
Overall Coverage 🟢 67.49%

Minimum allowed coverage is 0%, this run produced 67.49%

@vipinsamreddy
vipinsamreddy merged commit 01d5b32 into main Jul 23, 2026
7 checks passed
@vipinsamreddy
vipinsamreddy deleted the feature/similar-schools-primary branch July 23, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy deploy application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants