only load 7 days

This commit is contained in:
2025-11-10 10:52:57 -08:00
parent e04346a0f2
commit 5524d7308c
4 changed files with 81 additions and 66 deletions

View File

@@ -42,8 +42,13 @@ class FilevineClient:
self.headers["Authorization"] = f"Bearer {token}"
return token
def list_all_projects(self) -> List[Dict[str, Any]]:
"""Fetch all projects from Filevine API"""
def list_all_projects(self, latest_activity_since: Optional[str] = None) -> List[Dict[str, Any]]:
"""Fetch all projects from Filevine API, optionally filtered by latest activity date.
Args:
latest_activity_since: Optional date string in mm/dd/yyyy, mm-dd-yyyy, or yyyy-mm-dd format.
Only projects with activity since this date will be returned.
"""
base = f"{self.base_url}/Projects?limit=500"
results = []
last_count = None
@@ -60,6 +65,11 @@ class FilevineClient:
if last_count is not None:
offset = offset + last_count
params["offset"] = offset
# Add latestActivitySince filter if provided
if latest_activity_since:
params["latestActivitySince"] = latest_activity_since
r = requests.get(url, headers=self.headers, params=params, timeout=30)
r.raise_for_status()
page = r.json()

View File

@@ -179,7 +179,7 @@ class ProjectModel:
"service_attempt_date_1": self.service_attempt_date_1,
"contacts": self.contacts,
"ProjectEmailAddress": self.project_email_address,
"Number": self.number,
"number": self.number,
"IncidentDate": self.incident_date,
"ProjectId": self.project_id,
"ProjectName": self.project_name,

11
sync.py
View File

@@ -247,13 +247,15 @@ def process_project(index: int, total: int, project_data: dict, client: Filevine
from app import db # Import db from app
projects_ref = db.collection("projects")
from pprint import pprint
# pprint([p.get("number"), property_info, new_file_review])
# Add new projects
project_id = row.project_id
if project_id:
projects_ref.document(str(project_id)).set(row.to_dict())
print(f"Finished on {pid} ({index}/{total})")
print(f"Finished on {pid} Matter {row.number} ({index}/{total})")
return row.to_dict()
except Exception as e:
@@ -299,10 +301,13 @@ def main():
client = FilevineClient()
bearer = client.get_bearer_token()
# List projects (all pages)
projects = client.list_all_projects()
# List projects (all pages) with filter for projects updated in the last 7 days
from datetime import datetime, timedelta
seven_days_ago = (datetime.now() - timedelta(days=7)).strftime('%Y-%m-%d')
projects = client.list_all_projects(latest_activity_since=seven_days_ago)
#projects = [p for p in projects if (p.get("projectId") or {}).get("native") == 15914808]
#projects = projects[:10]
# Process projects in parallel
detailed_rows = process_projects_parallel(projects, client, 9)

View File

@@ -136,7 +136,7 @@
<tbody class="bg-slate-100 divide-y divide-slate-300">
{% for r in rows %}
<tr class="hover:bg-slate-200 transition-colors duration-150 ease-in-out">
<td class="px-4 py-3 text-sm text-slate-800" :class="{'hidden': !isColumnVisible('Matter Num')}"></td>
<td class="px-4 py-3 text-sm text-slate-800" :class="{'hidden': !isColumnVisible('Matter Num')}">{{ r.number }}</td>
<td class="px-4 py-3 text-sm text-slate-800" :class="{'hidden': !isColumnVisible('Client / Property')}">{{ r.client }}</td>
<td class="px-4 py-3 text-sm text-slate-800" :class="{'hidden': !isColumnVisible('Matter Description')}">{{ r.matter_description }}</td>
<td class="px-4 py-3 text-sm text-slate-800" :class="{'hidden': !isColumnVisible('Defendant 1')}">{{ r.defendant_1 }}</td>