fixes
This commit is contained in:
32
sync.py
32
sync.py
@@ -29,6 +29,22 @@ def convert_to_pacific_time(date_str):
|
||||
if not date_str:
|
||||
return ''
|
||||
|
||||
try:
|
||||
# Parse the UTC datetime
|
||||
utc_time = datetime.fromisoformat(date_str.replace('Z', '+00:00'))
|
||||
|
||||
# Set timezone to UTC
|
||||
utc_time = utc_time.replace(tzinfo=pytz.UTC)
|
||||
|
||||
# Convert to Pacific Time
|
||||
pacific_time = utc_time.astimezone(pytz.timezone('America/Los_Angeles'))
|
||||
|
||||
# Format as YYYY-MM-DD
|
||||
return pacific_time.strftime('%Y-%m-%d')
|
||||
except (ValueError, AttributeError) as e:
|
||||
print(f"[WARN] Date conversion failed for '{date_str}': {e}")
|
||||
return ''
|
||||
|
||||
|
||||
def extract_domains_from_emails(emails: List[str]) -> List[str]:
|
||||
"""Extract unique domains from a list of email addresses.
|
||||
@@ -155,6 +171,10 @@ def process_project(index: int, total: int, project_data: dict, client: Filevine
|
||||
# Extract default date
|
||||
default_date = convert_to_pacific_time(dates_and_deadlines.get("defaultDate")) or ''
|
||||
case_filed_date = convert_to_pacific_time(dates_and_deadlines.get("dateCaseFiled")) or ''
|
||||
cf = dates_and_deadlines.get("dateCaseFiled")
|
||||
from pprint import pprint
|
||||
print(f"CASE FILED {case_filed_date} {cf}")
|
||||
pprint(dates_and_deadlines)
|
||||
|
||||
# Extract motion hearing dates
|
||||
demurrer_hearing_date = convert_to_pacific_time(dates_and_deadlines.get("demurrerHearingDate")) or ''
|
||||
@@ -205,7 +225,6 @@ def process_project(index: int, total: int, project_data: dict, client: Filevine
|
||||
import itertools
|
||||
# valid_property_managers = list(itertools.chain(*))
|
||||
valid_property_managers = [e.get('address').lower() for pm in property_managers if pm and pm.get('emails') for e in pm.get('emails') if e and e.get('address')]
|
||||
pprint(valid_property_managers)
|
||||
|
||||
|
||||
row = ProjectModel(
|
||||
@@ -226,6 +245,7 @@ def process_project(index: int, total: int, project_data: dict, client: Filevine
|
||||
notice_service_date=notice_service_date,
|
||||
notice_expiration_date=notice_expiration_date,
|
||||
case_field_date=case_filed_date,
|
||||
case_filed_date=case_filed_date,
|
||||
daily_rent_damages=daily_rent_damages,
|
||||
default_date=default_date,
|
||||
demurrer_hearing_date=demurrer_hearing_date,
|
||||
@@ -326,7 +346,7 @@ def main():
|
||||
|
||||
# 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=14)).strftime('%Y-%m-%d')
|
||||
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]
|
||||
@@ -343,6 +363,14 @@ def main():
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
def sync_single(x):
|
||||
client = FilevineClient()
|
||||
z = process_project(0, 1, client.fetch_project_detail(x), client)
|
||||
from pprint import pprint
|
||||
|
||||
#pprint(z)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user