Skip to content

feat: enhance project area import with created and skipped counts#616

Merged
jirhiker merged 1 commit intostagingfrom
cli/import-project-areas
Mar 23, 2026
Merged

feat: enhance project area import with created and skipped counts#616
jirhiker merged 1 commit intostagingfrom
cli/import-project-areas

Conversation

@jirhiker
Copy link
Member

Why

This PR addresses the following problem / context:

  • Use bullet points here

How

Implementation summary - the following was changed / added / removed:

  • Use bullet points here

Notes

Any special considerations, workarounds, or follow-up work to note?

  • Use bullet points here

Copilot AI review requested due to automatic review settings March 23, 2026 20:19
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jirhiker jirhiker merged commit 989e678 into staging Mar 23, 2026
8 of 9 checks passed
@jirhiker jirhiker deleted the cli/import-project-areas branch March 23, 2026 20:19
Copy link
Contributor

Copilot AI left a comment

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 updates the project-area boundary import workflow to report additional outcomes (created and skipped) and to avoid updating group geometries when the imported geometry is unchanged.

Changes:

  • Extend ProjectAreaImportResult with created and skipped counters.
  • Add geometry equality checks to skip unchanged updates and introduce creation of missing Group rows for the target group_type.
  • Update the CLI command output to include created/skipped counts.

Reviewed changes

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

File Description
cli/project_area_import.py Adds created/skipped counters, group_type filtering, group creation for missing rows, and geometry comparison to skip unchanged updates.
cli/cli.py Prints created/skipped counts for the import command.

Comment on lines +121 to +125
if not groups:
new_group = Group(
name=location_name,
group_type=group_type,
project_area=project_area,
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The if not groups: branch now creates a new Group instead of recording an unmatched location, so unmatched_locations is never populated and any downstream "Unmatched locations" reporting becomes dead code. Either remove the unmatched_locations field/output or repurpose it to track skipped/invalid features if you still need operator visibility.

Copilot uses AI. Check for mistakes.
Comment on lines 1023 to +1026
typer.echo(f"Matched {result.matched} group row(s).")
typer.echo(f"Created {result.created} group(s).")
typer.echo(f"Updated {result.updated} group project area(s).")
typer.echo(f"Skipped {result.skipped} unchanged group(s).")
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

Existing CLI tests for import-project-area-boundaries (see tests/test_cli_commands.py::test_import_project_area_boundaries_updates_matching_groups) assert the old output/behavior (including "Unmatched locations"). With the new Created/Skipped output and the new-group creation path, those tests should be updated and extended to cover the created/skipped counts.

Copilot uses AI. Check for mistakes.
Comment on lines +140 to +143
new_wkt = project_area.desc

if old_wkt is None or not _geoms_equal(old_wkt, new_wkt):
group.project_area = project_area
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

new_wkt = project_area.desc is unlikely to be a plain WKT string (GeoAlchemy2 elements typically use .desc for SQL compilation), but _geoms_equal() expects WKT input for shapely.wkt.loads(). This can cause parse errors or false comparisons, leading to unnecessary updates or crashes. Use a real WKT string for comparison (e.g., the string returned by _geojson_to_multipolygon_wkt() or project_area.data) and consider computing it once to avoid repeated conversions.

Copilot uses AI. Check for mistakes.
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.

2 participants