Skip to content

Add fetch mp lookup and update Air functions to handle version updates - #147

Open
cjrace wants to merge 9 commits into
mainfrom
feature/144-fetch-mp-lookup
Open

Add fetch mp lookup and update Air functions to handle version updates#147
cjrace wants to merge 9 commits into
mainfrom
feature/144-fetch-mp-lookup

Conversation

@cjrace

@cjrace cjrace commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Brief overview of changes

Adds fetch_mp_lookup() to provide a convenient way to retrieve the latest MP lookup data from the maintained mp-lookup repository.

The function is exported, documented, supports optional progress messages, and provides an informative error if the data cannot be fetched.

Hit some issues with Air and decided this was the time to fix that and allow for updating of the Air version, given the recent breaking changes.

Why are these changes being made?

Resolves the request in #144 to make it easier for analysts in R so they don't have to memorise the URL.

Issue ticket number/s and link

Resolves #144

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.50794% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.01%. Comparing base (dedabb8) to head (8f5f138).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #147      +/-   ##
==========================================
+ Coverage   56.27%   59.01%   +2.73%     
==========================================
  Files          18       18              
  Lines        1642     1742     +100     
==========================================
+ Hits          924     1028     +104     
+ Misses        718      714       -4     

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dedabb8...8f5f138. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cjrace cjrace changed the title Add fetch mp lookup Add fetch mp lookup and update Air functions to handle version updates Aug 28, 2026
@cjrace
cjrace requested a lite review from Copilot August 28, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new exported helper to fetch the latest Westminster constituency→MP lookup from the maintained mp-lookup repo (addressing #144), and updates the Air formatter utilities/tests to handle minimum supported Air versions (including a new force reinstall option).

Changes:

  • Added fetch_mp_lookup() (exported + documented) and associated tests, including a live-shape guard test.
  • Refactored Air installer/formatter helpers to detect installed Air versions and reinstall when below a minimum supported version; expanded test coverage.
  • Regenerated/cleaned up Rd cross-links and small formatting changes across docs/NAMESPACE; updated package metadata/ignores.

Reviewed changes

Copilot reviewed 11 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/testthat/test-fetch_mp_lookup.R Adds unit + live-shape tests for the new fetch_mp_lookup() helper.
tests/testthat/test-air_formatter.R Expands tests to cover Air version detection and installer messaging/reinstall logic.
R/write_df_to_delta_utils.R Minor formatting/line-wrapping changes in permission-error checks.
R/fetch.R Introduces exported fetch_mp_lookup() with messaging and error handling.
R/air_formatter.R Adds Air path/version helpers, minimum supported version constant, and updates air_install() behavior/args.
NEWS.md Documents the new fetch_mp_lookup() and Air installer behavior changes.
NAMESPACE Exports fetch_mp_lookup() and reformats importFrom() blocks.
man/write_df_to_delta.Rd Fixes/normalizes Rd \seealso{} link formatting.
man/pretty_time.Rd Normalizes Rd \seealso{} link formatting.
man/pretty_time_taken.Rd Normalizes Rd \seealso{} link formatting.
man/pretty_num.Rd Normalizes Rd \seealso{} link formatting.
man/pretty_num_table.Rd Normalizes Rd \seealso{} link formatting.
man/pretty_filesize.Rd Normalizes Rd \seealso{} link formatting.
man/get_air_version.Rd Adds generated internal docs for get_air_version().
man/get_air_path.Rd Adds generated internal docs for get_air_path().
man/format_fy.Rd Normalizes Rd \seealso{} link formatting.
man/format_fy_reverse.Rd Normalizes Rd \seealso{} link formatting.
man/format_ay.Rd Normalizes Rd \seealso{} link formatting.
man/format_ay_reverse.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_wards.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_regions.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_mp_lookup.Rd Adds generated docs for the new exported fetch_mp_lookup().
man/fetch_mayoral.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_lsips.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_las.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_lads.Rd Normalizes Rd \seealso{} link formatting.
man/fetch_countries.Rd Normalizes Rd \seealso{} link formatting.
man/dfeR-package.Rd Updates author listing.
man/dfer_min_air_version.Rd Adds generated internal docs for dfer_min_air_version.
man/check_databricks_odbc.Rd Fixes/normalizes Rd \seealso{} link formatting.
man/air_install.Rd Updates docs for air_install() to include force and version behavior.
DESCRIPTION Updates testthat minimum version and roxygen2 config metadata.
.Rbuildignore Ignores the .posit/ directory in package builds.
.gitignore Ignores the .posit/ directory in git.
Files not reviewed (22)
  • man/air_install.Rd: Generated file
  • man/check_databricks_odbc.Rd: Generated file
  • man/dfeR-package.Rd: Generated file
  • man/dfer_min_air_version.Rd: Generated file
  • man/fetch_countries.Rd: Generated file
  • man/fetch_lads.Rd: Generated file
  • man/fetch_las.Rd: Generated file
  • man/fetch_lsips.Rd: Generated file
  • man/fetch_mayoral.Rd: Generated file
  • man/fetch_mp_lookup.Rd: Generated file
  • man/fetch_regions.Rd: Generated file
  • man/fetch_wards.Rd: Generated file
  • man/format_ay.Rd: Generated file
  • man/format_ay_reverse.Rd: Generated file
  • man/format_fy.Rd: Generated file
  • man/format_fy_reverse.Rd: Generated file
  • man/get_air_path.Rd: Generated file
  • man/get_air_version.Rd: Generated file
  • man/pretty_filesize.Rd: Generated file
  • man/pretty_num.Rd: Generated file
  • man/pretty_num_table.Rd: Generated file
  • man/pretty_time.Rd: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread R/air_formatter.R
Comment thread tests/testthat/test-fetch_mp_lookup.R
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@matthewberobinson

Copy link
Copy Markdown

It's all looking good, there's just a couple of issues around mockery

  1. It's not included in the package so tests fail
image
  1. I'm not sure that it's very clear what would be breaking when using it and I don't think it streamlines the code much though I might be missing something here so welcome pushback, it does make it so that changes to the underlying function get pushes up automatically to the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add fetch_mp_lookup() function

3 participants