feat: enhance project area import with created and skipped counts#616
feat: enhance project area import with created and skipped counts#616
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
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
ProjectAreaImportResultwithcreatedandskippedcounters. - Add geometry equality checks to skip unchanged updates and introduce creation of missing
Grouprows for the targetgroup_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. |
| if not groups: | ||
| new_group = Group( | ||
| name=location_name, | ||
| group_type=group_type, | ||
| project_area=project_area, |
There was a problem hiding this comment.
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.
| 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).") |
There was a problem hiding this comment.
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.
| new_wkt = project_area.desc | ||
|
|
||
| if old_wkt is None or not _geoms_equal(old_wkt, new_wkt): | ||
| group.project_area = project_area |
There was a problem hiding this comment.
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.
Why
This PR addresses the following problem / context:
How
Implementation summary - the following was changed / added / removed:
Notes
Any special considerations, workarounds, or follow-up work to note?