feat: Implement comprehensive project data model and synchronization system

- Added ProjectModel class in models/project_model.py to define structure for Filevine project data with proper type hints and conversion methods (to_dict/from_dict)
- Implemented get_firestore_document() helper function in app.py for retrieving specific Firestore documents
- Enhanced dashboard pagination in app.py with improved error handling and debugging output for property contacts and project IDs
- Overhauled sync.py with:
  * Parallel processing using ThreadPoolExecutor for efficient project synchronization
  * Comprehensive extraction of project data from Filevine forms (newFileReview, datesAndDeadlines, propertyInfo, etc.)
  * Improved error handling and logging throughout the sync process
  * Proper handling of date conversions and field mappings from Filevine to Firestore
  * Added property contacts email extraction and viewing_emails array population
  * Added support for filtering projects by specific ProjectId (15914808) for targeted sync
- Added proper initialization of Filevine client in worker threads using thread-local storage
- Improved handling of optional fields and default values in ProjectModel
- Added detailed logging for progress tracking during synchronization

This implementation enables reliable synchronization of Filevine project data to Firestore with proper data modeling and error handling, supporting the dashboard's data requirements.
This commit is contained in:
2025-11-09 20:21:53 -08:00
parent 0d0d0554a6
commit 662be72f6a
3 changed files with 61 additions and 14 deletions

View File

@@ -68,7 +68,9 @@ class ProjectModel:
project_id: str = "",
project_name: str = "",
project_url: str = "",
property_contacts: Dict[str, Any] = None):
property_contacts: Dict[str, Any] = None,
viewing_emails: List[str] = None
):
self.client = client
self.matter_description = matter_description
@@ -124,6 +126,7 @@ class ProjectModel:
self.project_name = project_name
self.project_url = project_url
self.property_contacts = property_contacts or {}
self.viewing_emails = viewing_emails or []
def to_dict(self) -> Dict[str, Any]:
"""Convert the ProjectModel to a dictionary for Firestore storage."""
@@ -181,7 +184,8 @@ class ProjectModel:
"ProjectId": self.project_id,
"ProjectName": self.project_name,
"ProjectUrl": self.project_url,
"property_contacts": self.property_contacts
"property_contacts": self.property_contacts,
"viewing_emails": self.viewing_emails
}
@classmethod
@@ -241,5 +245,6 @@ class ProjectModel:
project_id=data.get("ProjectId", ""),
project_name=data.get("ProjectName", ""),
project_url=data.get("ProjectUrl", ""),
property_contacts=data.get("property_contacts", {})
property_contacts=data.get("property_contacts", {}),
viewing_emails=data.get("viewing_emails", [])
)