feat: add /api/map/neighbors/{familyId} endpoint#8134
Merged
Conversation
… map neighbors to use FamilyMiddleware
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Map API capability to fetch “neighbor” families by distance, leveraging mjaschen/phpgeo (Vincenty) for distance calculation while keeping legacy geodesy helpers as fallback/for display.
Changes:
- Add
GET /api/map/neighbors/{familyId}endpoint (withFamilyMiddleware) to return nearby families, distances, bearings, and household members. - Add a Cypress API spec to validate the new endpoint behavior against seeded demo data.
- Update Slim MVC skill docs to document the
FamilyMiddlewarepattern for routes withfamilyId.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/api/routes/map.php |
Adds the new /map/neighbors/{familyId} endpoint and OpenAPI annotations. |
cypress/e2e/api/map-neighbors.spec.js |
Adds an API test for the neighbors endpoint using an admin API key. |
.agents/skills/churchcrm/slim-mvc-skill.md |
Documents using FamilyMiddleware for routes that accept familyId. |
- Add GET /map/neighbors/{familyId} using FamilyMiddleware for family
lookup/validation; returns nearby families sorted by distance
- Pre-filter candidates with a lat/lng bounding box query before
per-record distance calculation (avoids full table scan)
- Use GeoUtils for distance and bearing (drops undeclared phpgeo dep)
- Fix OA annotation: correct path, familyId as in=path, valid syntax
- Use renderErrorJSON + gettext for error responses
- Move Cypress spec to cypress/e2e/api/private/; use
makePrivateAdminAPICall helper; assert all response fields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merged
DawoudIO
pushed a commit
that referenced
this pull request
Mar 3, 2026
This PR updates the locale translation strings extracted from source
code.
## Triggered By
Commit: `b2791b6a055a1106d96d461cbb9a22e1059e4087`
Message: feat: add /api/map/neighbors/{familyId} endpoint (#8134)
## What changed
- Add `GET /api/map/neighbors/{familyId}` endpoint using
`FamilyMiddleware` for family lookup and validation
- Pre-filter candidate families with a lat/lng bounding box query before
per-record distance calculation in PHP (avoids full table scan)
- Use existing `GeoUtils` for distance and bearing — drops the
undeclared `mjaschen/phpgeo` dependency (not in composer.json/lock;
Spherical Law of Cosines is accurate enough for finding church
neighbors)
- Fix OpenAPI annotation: correct path template, `familyId` as
`in=path`, valid `@OA\Get()` syntax
- Use `renderErrorJSON` + `gettext()` for error responses (consistent
with other routes)
- Update agent skill docs: document `FamilyMiddleware` pattern for
routes with `familyId`
## Testing
Ensure demo DB is loaded, then run the Cypress spec or call the endpoint
directly:
```
GET /api/map/neighbors/{familyId}?maxNeighbors=5&maxDistance=50
```
Cypress spec: `cypress/e2e/api/private/map-neighbors.spec.js`
## Changes
- Updated `locale/terms/messages.po` with new/modified translatable
strings
- Updated JSON locale keys
## Next Steps
- Review the new strings that need translation
- Merge this PR to update the base locale file
- Upload to POEditor for translation if needed
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
GET /api/map/neighbors/{familyId}endpoint usingFamilyMiddlewarefor family lookup and validationGeoUtilsfor distance and bearing — drops the undeclaredmjaschen/phpgeodependency (not in composer.json/lock; Spherical Law of Cosines is accurate enough for finding church neighbors)familyIdasin=path, valid@OA\Get()syntaxrenderErrorJSON+gettext()for error responses (consistent with other routes)FamilyMiddlewarepattern for routes withfamilyIdTesting
Ensure demo DB is loaded, then run the Cypress spec or call the endpoint directly:
Cypress spec:
cypress/e2e/api/private/map-neighbors.spec.js