feat: ZIP → rep lookup, member page redesign, letter improvements
ZIP lookup (GET /api/members/by-zip/{zip}):
- Two-step geocoding: Nominatim (ZIP → lat/lng) then Census TIGERweb
Legislative identify (lat/lng → congressional district via GEOID)
- Handles at-large states (AK, DE, MT, ND, SD, VT, WY)
- Added rep_lookup health check to admin External API Health panel
congress_api.py fixes:
- parse_member_from_api: normalize state full name → 2-letter code
(Congress.gov returns "Florida", DB expects "FL")
- parse_member_from_api: read district from top-level data field,
not current_term (district is not inside the term object)
Celery beat: schedule sync_members daily at 1 AM UTC so chamber,
district, and contact info stay current without manual triggering
Members page redesign: photo avatars, party/state/chamber chips,
phone + website links, ZIP lookup form to find your reps
Draft letter improvements: pass rep_name from ZIP lookup so letter
opens with "Dear Representative Franklin," instead of generic salutation;
add has_document filter to bills list endpoint
UX additions: HelpTip component, How It Works page, "How it works"
sidebar nav link, collections page description copy
Authored-By: Jack Levy
This commit is contained in:
@@ -35,7 +35,9 @@ def is_referral_action(action_text: str) -> bool:
|
||||
return any(kw in t for kw in _REFERRAL_KEYWORDS)
|
||||
|
||||
|
||||
def _build_payload(bill, action_summary: str, milestone_tier: str = "progress") -> dict:
|
||||
def _build_payload(
|
||||
bill, action_summary: str, milestone_tier: str = "progress", source: str = "bill_follow"
|
||||
) -> dict:
|
||||
from app.config import settings
|
||||
base_url = (settings.PUBLIC_URL or settings.LOCAL_URL).rstrip("/")
|
||||
return {
|
||||
@@ -44,6 +46,7 @@ def _build_payload(bill, action_summary: str, milestone_tier: str = "progress")
|
||||
"brief_summary": (action_summary or "")[:300],
|
||||
"bill_url": f"{base_url}/bills/{bill.bill_id}",
|
||||
"milestone_tier": milestone_tier,
|
||||
"source": source,
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +72,7 @@ def emit_bill_notification(
|
||||
if not followers:
|
||||
return 0
|
||||
|
||||
payload = _build_payload(bill, action_summary, milestone_tier)
|
||||
payload = _build_payload(bill, action_summary, milestone_tier, source="bill_follow")
|
||||
count = 0
|
||||
for follow in followers:
|
||||
if _is_duplicate(db, follow.user_id, bill.bill_id, event_type):
|
||||
@@ -100,7 +103,7 @@ def emit_member_follow_notifications(
|
||||
if not followers:
|
||||
return 0
|
||||
|
||||
payload = _build_payload(bill, action_summary, milestone_tier)
|
||||
payload = _build_payload(bill, action_summary, milestone_tier, source="member_follow")
|
||||
count = 0
|
||||
for follow in followers:
|
||||
if _is_duplicate(db, follow.user_id, bill.bill_id, event_type):
|
||||
@@ -140,7 +143,7 @@ def emit_topic_follow_notifications(
|
||||
if not followers:
|
||||
return 0
|
||||
|
||||
payload = _build_payload(bill, action_summary, milestone_tier)
|
||||
payload = _build_payload(bill, action_summary, milestone_tier, source="topic_follow")
|
||||
count = 0
|
||||
for follow in followers:
|
||||
if _is_duplicate(db, follow.user_id, bill.bill_id, event_type):
|
||||
|
||||
Reference in New Issue
Block a user