8.8 KiB
SearchAreaView.vue Enhanced Triple Migration Pattern Pre-Migration Audit
Migration Candidate: src/views/SearchAreaView.vue
Audit Date: 2025-07-09
Status: 🔄 PRE-MIGRATION AUDIT
Risk Level: Medium (location-based search feature)
File Size: 290 lines
Estimated Time: 8-12 minutes
🔍 Component Overview
SearchAreaView.vue is a location-based search management component that allows users to set and manage geographic search areas using interactive Leaflet maps. This component is essential for users who want to filter content by geographic proximity.
Core Functionality
- Interactive Map Interface: Leaflet map integration for geographic area selection
- Search Box Management: Create, store, and delete geographic search areas
- Location Storage: Persist search box preferences in local database
- Bounding Box Calculation: Calculate geographic boundaries from user interactions
- Privacy Protection: Location data stored locally only, not on servers
User Journey
- User navigates to search area management from discovery or settings
- Component loads existing stored search box (if any)
- User interacts with map to set new search area or modify existing
- System calculates bounding box coordinates automatically
- User saves location preference or deletes existing preference
- Settings are stored locally for nearby search filtering
Technical Features
- Leaflet Maps Integration: Interactive map with marker and rectangle overlays
- Geographic Calculations: Automatic bounding box size estimation
- Database Integration: Settings storage for search preferences
- Real-time Updates: Dynamic map interactions with immediate visual feedback
- Privacy-First Design: Location data never sent to external servers
📋 Migration Requirements Analysis
✅ Phase 1: Database Migration (Estimated: 2-3 minutes)
Current Legacy Patterns:
// 🔴 Legacy pattern - databaseUtil import
import * as databaseUtil from "../db/databaseUtil";
// 🔴 Legacy pattern - settings retrieval (line 146)
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
// 🔴 Legacy pattern - settings update (line 207)
databaseUtil.updateDefaultSettings({ searchBoxes });
// 🔴 Legacy pattern - settings update (line 242)
await databaseUtil.updateDefaultSettings({
searchBoxes: "[]",
filterFeedByNearby: false,
});
Migration Requirements:
- Add PlatformServiceMixin to component mixins
- Replace
databaseUtil.retrieveSettingsForActiveAccount()
withthis.$accountSettings()
- Replace
databaseUtil.updateDefaultSettings()
calls withthis.$updateSettings()
- Remove legacy
import * as databaseUtil from "../db/databaseUtil";
- Add comprehensive component documentation
✅ Phase 2: SQL Abstraction (Estimated: 1 minute)
Current State:
- ✅ No Raw SQL: Component does not use raw SQL queries
- ✅ Service Layer Ready: All database operations can use service methods
- ✅ Type Safe: All operations use proper TypeScript interfaces
Migration Requirements:
- Verify no raw SQL queries exist
- Confirm all database operations use service layer appropriately
- Document SQL abstraction compliance
✅ Phase 3: Notification Migration (Estimated: 3-4 minutes)
Current Legacy Patterns:
// 🔴 Legacy pattern - success notification (line 212)
this.$notify({
group: "alert",
type: "success",
title: "Saved",
text: "That has been saved in your preferences...",
}, 7000);
// 🔴 Legacy pattern - error notification (line 221, 245)
this.$notify({
group: "alert",
type: "danger",
title: "Error Updating Search Settings",
text: "Try going to a different page and then coming back.",
}, 5000);
// 🔴 Legacy pattern - warning notification (line 235)
this.$notify({
group: "alert",
type: "warning",
title: "No Location Selected",
text: "Select a location on the map.",
}, 5000);
Migration Requirements:
- Add 4 notification constants to
src/constants/notifications.ts
:NOTIFY_SEARCH_AREA_SAVED
- Search area saved successfullyNOTIFY_SEARCH_AREA_ERROR
- Error updating search settingsNOTIFY_SEARCH_AREA_NO_LOCATION
- No location selected warningNOTIFY_SEARCH_AREA_DELETED
- Search area deleted successfully
- Import notification helper system (
createNotifyHelpers
,TIMEOUTS
) - Replace all 3
$notify()
calls withthis.notify.success()
,this.notify.error()
, andthis.notify.warning()
- Initialize notification helper system in component
✅ Phase 4: Template Streamlining (Estimated: 2-3 minutes)
Current Template Patterns:
<!-- 🔴 Inline click handler -->
@click="$router.back()"
<!-- 🔴 Repeated button styling patterns -->
class="m-4 px-4 py-2 rounded-md bg-blue-200 text-blue-500"
Migration Requirements:
- Add computed property for consistent button styling
- Extract
@click="$router.back()"
togoBack()
method - Consider extracting map interaction methods if complex
- Add method documentation for all user interaction handlers
🎯 Technical Specifications
Database Operations
- Settings Retrieval:
this.$accountSettings()
for loading search box preferences - Settings Updates:
this.$updateSettings()
for storing geographic search areas - Data Types: Geographic bounding box data with latitude/longitude coordinates
- Privacy: All location data stored locally, never transmitted to servers
Notification System
- Success Notifications: Search area save confirmation with usage guidance
- Error Notifications: Database update failures with retry instructions
- Warning Notifications: User input validation for location selection
- Timeout Management: Appropriate timeouts for different notification types
Template Optimization
- Button Styling: Consistent class application for all action buttons
- Method Extraction: Clean separation of UI interactions and business logic
- Event Handling: Proper method-based event handling for maintainability
🔧 Complexity Assessment
Migration Complexity: Medium
- Database Operations: 3 database calls requiring mixin integration
- Notification Patterns: 3 notifications requiring constant migration
- Template Structure: Simple template with basic button interactions
- Geographic Logic: Complex coordinate calculations (unchanged by migration)
- Map Integration: Leaflet map integration (unchanged by migration)
Risk Assessment: Medium
- Functionality Risk: Medium (location features must work correctly)
- Data Risk: Low (no data transformation required)
- User Impact: Medium (important for location-based search)
- Security Risk: Low (geographic data only, no sensitive information)
Estimated Time Breakdown:
- Phase 1 (Database): 2-3 minutes
- Phase 2 (SQL): 1 minute (minimal work)
- Phase 3 (Notifications): 3-4 minutes
- Phase 4 (Template): 2-3 minutes
- Total Estimated: 8-12 minutes
🎯 Success Criteria
Technical Requirements:
- ✅ All databaseUtil imports removed
- ✅ All database operations use PlatformServiceMixin
- ✅ All $notify calls use helper system + constants
- ✅ Template logic moved to methods where appropriate
- ✅ TypeScript compilation successful
- ✅ All imports updated and optimized
Functional Requirements:
- ✅ Map interaction works correctly
- ✅ Search area creation functions properly
- ✅ Search area deletion works correctly
- ✅ Location storage persists correctly
- ✅ Geographic calculations remain accurate
- ✅ Privacy protections maintained
User Experience Requirements:
- ✅ All user interactions work smoothly
- ✅ Visual feedback functions correctly
- ✅ Error handling provides clear guidance
- ✅ Success confirmations are informative
- ✅ Map performance remains optimal
🚀 Migration Readiness
Pre-Conditions Met:
- ✅ Component clearly identified and analyzed
- ✅ Migration patterns documented
- ✅ Testing strategy defined
- ✅ Success criteria established
- ✅ Risk assessment completed
Migration Approval: ✅ READY FOR MIGRATION
Recommendation: Proceed with migration following the Enhanced Triple Migration Pattern. This is a well-structured component with clear migration requirements and medium complexity.
Next Steps:
- Start time tracking with
./scripts/time-migration.sh SearchAreaView.vue start
- Begin Phase 1: Database Migration
- Complete all four phases systematically
- Validate functionality with map interactions
- Human test geographic search functionality
Migration Candidate: SearchAreaView.vue
Complexity Level: Medium
Ready for Migration: ✅ YES
Expected Performance: 8-12 minutes (potentially faster with current momentum)