Spaces:
Running
Running
| """Clear all entries with wrong user_id from document_metadata collection.""" | |
| from services.chroma_service import ChromaService | |
| def clear_old_data(): | |
| print("Connecting to ChromaDB...") | |
| c = ChromaService() | |
| # Get all entries with the wrong user_id | |
| data = c.metadata_collection.get(where={"user_id": "jashdoshi"}) | |
| count = len(data['ids']) | |
| print(f"Found {count} entries with user_id='jashdoshi' (old migration)") | |
| if count > 0 and data['ids']: | |
| print("Deleting these entries...") | |
| c.metadata_collection.delete(ids=data['ids']) | |
| print(f"Deleted {count} entries.") | |
| # Verify | |
| remaining = c.metadata_collection.get() | |
| print(f"Remaining entries in collection: {len(remaining['ids'])}") | |
| if __name__ == "__main__": | |
| clear_old_data() | |