@@ -20,7 +20,8 @@ def get_updated_contact_data():
20
20
when volgistics.last_shift_date > now() - interval '1 year' then 'Active' else 'InActive'
21
21
end as "volunteerStatus",
22
22
shelterluv.foster_start as "fosterStartDate",
23
- shelterluv.foster_end as "fosterEndDate",
23
+ null as "fosterEndDate",
24
+ shelterluv.latest_foster_event as "latestFosterEvent",
24
25
volgistics.first_volunteer_date as "firstVolunteerDate",
25
26
volgistics.last_shift_date as "lastShiftDate",
26
27
volgistics.total_hours as "totalVolunteerHours",
@@ -39,9 +40,8 @@ def get_updated_contact_data():
39
40
left join (
40
41
select
41
42
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
45
45
from shelterluvpeople p
46
46
left join sl_animal_events sae on sae.person_id::varchar = p.internal_id
47
47
inner join pdp_contacts pc on pc.source_id = p.internal_id
0 commit comments