perf: Optimize recommendation system and improve error handling

- Fix N+1 query problem in preset package fetching
  * Search with limit 5 to find best matches
  * Case-insensitive package name matching
  * Fallback to most popular when no exact match

- Improve category filtering accuracy
  * Update category mapping to match database schema
  * Remove duplicate packages in category fetching
  * Better distribution across categories

- Add version control for localStorage profile
  * Support future schema migrations
  * Auto-migrate old profiles to new version
  * Persist version in localStorage

- Enhance error handling
  * Specific error messages for 400/500/404 responses
  * Network error detection
  * User-friendly error messages in UI

- Fix OS detection fallback
  * Default to ubuntu when detection returns unknown
  * Prevent empty OS selection in onboarding

- Add better API validation
  * Explicit limit range validation (1-50)
  * Clear error messages for invalid inputs
This commit is contained in:
ersaayan
2025-11-22 17:47:52 +03:00
parent bcf8652728
commit f8fffdce83
6 changed files with 88 additions and 30 deletions
+1
View File
@@ -21,6 +21,7 @@ export type ExperienceLevel = "beginner" | "intermediate" | "advanced";
* User profile stored in localStorage
*/
export interface UserProfile {
version: number; // Schema version for future migrations
categories: UserCategory[];
detectedOS?: string;
selectedOS?: string; // Manual override