@@ -20,7 +20,8 @@ def get_updated_contact_data():
2020 when volgistics.last_shift_date > now() - interval '1 year' then 'Active' else 'InActive'
2121 end as "volunteerStatus",
2222 shelterluv.foster_start as "fosterStartDate",
23- shelterluv.foster_end as "fosterEndDate",
23+ null as "fosterEndDate",
24+ shelterluv.latest_foster_event as "latestFosterEvent",
2425 volgistics.first_volunteer_date as "firstVolunteerDate",
2526 volgistics.last_shift_date as "lastShiftDate",
2627 volgistics.total_hours as "totalVolunteerHours",
@@ -39,9 +40,8 @@ def get_updated_contact_data():
3940 left join (
4041 select
4142 matching_id, array_agg(distinct p.internal_id) as person_ids,
42- max(case when event_type=1 then to_timestamp(time) else null end) adopt,
43- min(case when event_type=2 then to_timestamp(time) else null end) foster_start,
44- max(case when event_type=5 then to_timestamp(time) else null end) foster_end
43+ min(case when event_type in (2,5) then to_timestamp(time) else null end) foster_start,
44+ max(case when event_type in (2,5) then to_timestamp(time) else null end) latest_foster_event
4545 from shelterluvpeople p
4646 left join sl_animal_events sae on sae.person_id::varchar = p.internal_id
4747 inner join pdp_contacts pc on pc.source_id = p.internal_id
0 commit comments