Conversation
…p in user_related.py
…p in user_related.py
…p in user_related.py
There was a problem hiding this comment.
Pull request overview
This PR introduces database schema changes and a new model to support data collection campaigns, refactors the ChatMessage model to use inferred users, and adds click tracking for returned documents.
Changes:
- Added
DataCollectionCampaignManagementmodel to track data collection campaigns with activation status and end dates - Refactored
ChatMessageto associate withinferred_user_idinstead ofuser_id, and addedconversation_idandrolefields - Added
is_clickedfield toReturnedDocumentfor tracking user interactions
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| welearn_database/data/models/user_related.py | Updated ChatMessage to use inferred_user_id, added role and conversation_id fields; added is_clicked to ReturnedDocument; added DataCollectionCampaignManagement model |
| welearn_database/alembic/versions/2ad4895b2674_data_collection.py | Migration script to create data_collection_campaign_management table and modify chat_message and returned_document tables |
| welearn_database/alembic/env.py | Added production database safety check with confirmation prompt before running migrations |
| tests/test_user_related.py | Comprehensive CRUD tests for all user-related models including new DataCollectionCampaignManagement and updated ChatMessage fields |
| pyproject.toml | Version bump to 1.3.0 |
| .env.example | Added example environment configuration for database connectivity and logging |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if "prod" in os.getenv("PG_HOST").lower(): | ||
| print("Connecting to production database for migrations!") | ||
| input("Press Enter to continue...") | ||
| elif "dev" in os.getenv("PG_HOST" "").lower(): |
There was a problem hiding this comment.
Missing comma between arguments in os.getenv call. Should be os.getenv('PG_HOST', '') instead of os.getenv('PG_HOST' '').
| elif "dev" in os.getenv("PG_HOST" "").lower(): | |
| elif "dev" in os.getenv("PG_HOST", "").lower(): |
| ), | ||
| nullable=False, | ||
| ) | ||
| is_clicked: Mapped[bool] = mapped_column(default=False) |
There was a problem hiding this comment.
The default value should be set using server_default instead of default for consistency with database-level defaults and to ensure the value is set even when rows are inserted directly via SQL.
| is_clicked: Mapped[bool] = mapped_column(default=False) | |
| is_clicked: Mapped[bool] = mapped_column(default=False, server_default="false") |
This pull request introduces significant improvements to the user-related data model and database schema, focusing on enhanced support for inferred users, chat message tracking, and data collection campaigns. It adds a new Alembic migration, updates models, and introduces comprehensive CRUD tests for these changes. Additionally, it updates configuration and environment files for better usability and safety.
Database and Model Enhancements:
DataCollectionCampaignManagementmodel and corresponding table to track data collection campaigns, including fields for activity status and end date. [1] [2]ChatMessagemodel to associate messages withinferred_user_idinstead ofuser_id, and added new fields:conversation_idandrole. Updated relationships accordingly. [1] [2] [3]is_clickedboolean column to theReturnedDocumentmodel to track user interactions with returned documents. [1] [2]Testing Improvements:
tests/test_user_related.pyto verify CRUD operations for all major user-related models, including the new and updated fields.Migration and Environment Safety:
Configuration Updates:
.env.examplefile with recommended environment variables for database connectivity and logging.pyproject.tomlto 1.3.0 to reflect these changes.