-
Notifications
You must be signed in to change notification settings - Fork 0
Fix vector_full_scan error and implement code quality improvements #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
|
@copilot let's to the changes you noticed to improve the code quality |
…lities Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
I've implemented the code quality improvements identified in my analysis. Changes in commit ba30044: New modules created:
Improvements made:
All existing functionality preserved, comprehensive tests passing. The codebase is now more maintainable with ~250 lines of duplication removed. |
…corator Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
db/operations.py
Outdated
| """ | ||
| DEPRECATED: Use db.connection.get_db_connection() instead. | ||
| This function is maintained for backward compatibility. | ||
| """ | ||
| from .connection import get_db_connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I don't care about backward comp atibility,remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the deprecated _get_connection wrapper function completely. Changes in commit 90fbbaf:
- Removed wrapper function (lines 23-32)
- Added direct import of
get_db_connectionfromdb.connection - Replaced all 18 usages with
get_db_connection(path, timeout=5.0, enable_wal=True)
All database operations now use the unified connection function directly with no backward compatibility layer.
…irectly Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
Fix vector_full_scan error and implement code quality improvements
Issues Fixed
1. Vector Search Fails with "unable to retrieve context" Error ✅
Root Cause: The
search_vectors()function calledvector_full_scanbefore initializing the vector index withvector_init.Solution: Modified
search_vectors()to initialize vector index before searching.2. Dimension Mismatch After Clearing Project Data ✅
Root Cause:
clear_project_data()deleted chunks but left dimension metadata.Solution: Modified
clear_project_data()to clear vector dimension metadata.Code Quality Improvements Implemented ✅
1. Unified Database Connection Module (
db/connection.py)2. Generic Retry Utilities (
utils/retry.py)@retry_on_exception,@retry_on_db_lockeddecorators3. Refactored Operations (
db/operations.py)_retry_on_db_locked()wrapper function_get_connection()wrapper functionget_db_connection()directly withtimeout=5.0, enable_wal=True@retry_on_db_lockeddecorator directlyget_db_connection()directly:init_db(),get_project_stats(),list_files(),clear_project_data()get_file_by_path(),set_project_metadata(),set_project_metadata_batch()get_project_metadata(),delete_file_by_path()_init_registry_db(),create_project(),get_project(),get_project_by_id()list_projects(),update_project_status(),update_project_settings(),delete_project()4. Refactored Vector Operations (
db/vector_operations.py)connect_db()wrapper (used by external modules)Testing Results
✅ Database initialization works correctly
✅ Vector operations work correctly
✅ Database stats retrieval works correctly
✅ Project operations work correctly
✅ All retry logic functions properly
✅ No breaking changes
Code Removed
_retry_on_db_locked()function_get_connection()functionImpact: Eliminates ~320 lines of duplicate/wrapper code, improves consistency, and makes the codebase cleaner and more maintainable. All code now uses the unified utilities directly without any backward compatibility layers.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.