Changelog - Locations App¶
All notable changes to the Locations app will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[2.0.0] - 2025-09-12¶
Added¶
Smart Location System¶
- Hybrid Geocoding: Intelligent location detection that reuses existing location data to reduce API calls
- Dynamic Boundaries: Automatic neighborhood boundary calculation based on user distribution
- Crowd-Sourced Naming: Community-driven location naming with weighted consensus system
- Confidence Scoring: Quality metrics for locations based on user participation and name agreement
New Database Fields¶
center_latitudeandcenter_longitudefor calculated location centersestimated_radiusfor dynamic boundary management (200m-2km range)confidence_scorefor location quality assessment (0.0-1.0 scale)name_suggestions(JSON) for tracking community name votestotal_usersfor user count trackinglast_boundary_updatefor boundary recalculation timestampsneeds_verification,is_auto_generated,moderator_approvedfor quality management
New Models¶
- LocationNameSuggestion: Tracks individual user name suggestions with vote weights
- LocationModerationLog: Audit trail for all location modifications and admin actions
Smart Location APIs¶
POST /api/locations/locations/smart_update/- Intelligent location update with boundary detectionPOST /api/locations/locations/{id}/suggest_name/- Community name suggestion systemGET /api/locations/locations/{id}/name_suggestions/- View grouped name suggestions with fuzzy matchingGET /api/locations/locations/nearby/- Find existing locations near coordinatesGET /api/locations/locations/search/- Enhanced search with confidence scoring
Administrative Features¶
POST /api/locations/locations/{id}/flag_for_review/- Flag locations for moderator reviewGET /api/locations/locations/analytics/- System analytics for staffPOST /api/locations/locations/{id}/update_boundary/- Manual boundary recalculation- Enhanced Django admin interface with confidence indicators and bulk actions
Name Consensus System¶
- Weighted Voting: User votes weighted by account age, activity, and verification status
- Fuzzy Matching: Automatic grouping of similar name suggestions (85% similarity threshold)
- Quality Safeguards: Profanity filtering, length validation, and character restrictions
- Progressive Consensus: Names update when new consensus reaches 60% confidence with 10%+ improvement
Boundary Management¶
- Automatic Recalculation: Boundaries adjust as more users join locations
- Centroid Calculation: Geographic center computed from user coordinates
- 90th Percentile Radius: Optimal coverage using statistical distribution
- Bounds Enforcement: Minimum 200m, maximum 2km radius limits
Enhanced¶
Existing APIs¶
- Location List API: Added confidence scoring, smart filtering, and quality indicators
- Location Detail API: Enhanced with boundary information and suggestion analytics
- Search Functionality: Improved with fuzzy matching and confidence-based ranking
Database Performance¶
- Added spatial indexes for geographic queries
- Optimized count aggregations using subqueries
- Database constraints for data integrity
Admin Interface¶
- Color-coded confidence scoring display
- Bulk boundary recalculation actions
- Location flagging and approval workflows
- Detailed suggestion management views
- Comprehensive moderation logging
Migration Notes¶
Database Migration¶
- All new fields have safe defaults for production deployment
- Existing location data automatically migrated to new structure
center_latitude/longitudepopulated from existing coordinates- Confidence scores calculated based on data completeness and user counts
Management Commands¶
migrate_location_data- Migrate existing location data to smart system--dry-runoption for safe preview of changes--recalculate-boundariesfor boundary updates- Duplicate location detection and reporting
Breaking Changes¶
Model Changes¶
namefield is now non-editable (auto-generated from hierarchy or consensus)- Location creation now requires coordinate validation
- JSON fields require MySQL 5.7.8+ or fallback to TextField with serialization
API Behavior Changes¶
- Location update now uses smart boundary detection instead of simple coordinate matching
- Name suggestions response format changed to grouped structure by default
- Individual suggestions now require
show_individual=trueparameter
Performance Improvements¶
- Reduced API Costs: 70-90% reduction in geocoding API calls after initial location creation
- Efficient Queries: Spatial database queries for boundary detection
- Caching Strategy: Smart caching of frequently accessed location data
- Batch Operations: Optimized bulk location processing
Security Enhancements¶
- Vote Weight Validation: New user accounts have reduced voting influence
- Rate Limiting: Protection against suggestion spam (configurable)
- Input Validation: Comprehensive name suggestion filtering
- Audit Logging: Complete trail of all location modifications
[1.0.0] - 2024-01-XX¶
Initial Release¶
Core Features¶
- Hierarchical location model with 17 geographic levels
- Coordinate-based location storage with unique constraints
- Basic location management APIs (CRUD operations)
- Geographic search and filtering capabilities
Geographic Hierarchy¶
- Administrative levels: Country, State, County, District
- Urban areas: City, Town, Village, Hamlet, Municipality
- Neighborhoods: Suburb, Borough, Quarter, Neighbourhood
- Specific places: Road, Building, Commercial, Amenity
APIs¶
GET /api/locations/- List and filter locationsGET /api/locations/{id}/- Location details- Location search with text matching across all fields
- Geographic filtering by administrative levels
- Activity-based sorting by post and store counts
Integration¶
- Posts association with locations
- Store geographic positioning
- User location assignment
- Community location linking
Utilities¶
get_or_create_location()for intelligent location matching- Automatic name generation from hierarchy
- Duplicate prevention logic
Migration Guide¶
Upgrading from v1.0 to v2.0¶
Prerequisites¶
- Django 3.1+ required for JSONField support
- MySQL 5.7.8+ recommended (or use TextField fallback)
- Install dependencies:
fuzzywuzzy[speedup],python-levenshtein
Migration Steps¶
- Backup Database
- Update Dependencies
- Run Migrations
- Populate Existing Data
python manage.py migrate_location_data --dry-run # Preview
python manage.py migrate_location_data # Execute
- Verify Migration
Frontend Updates Required¶
Update location detection code to use smart endpoints:
// Replace simple location updates
await api.post("/api/users/update-location/", locationData);
// With smart location updates
await api.post("/api/locations/locations/smart_update/", {
latitude,
longitude,
geocoded_data,
});
Add name suggestion UI components for enhanced user experience.
Backward Compatibility¶
- All existing APIs continue to work unchanged
- Smart features are additive enhancements
- Gradual migration path - can deploy without immediate frontend changes
- Existing location data automatically enhanced with confidence scores
Support¶
For questions about the smart location system implementation or migration assistance, please refer to the documentation or create an issue in the project repository.