-- Rule 4c
select l.first_name, l.last_name, p.name, o1.create_time, o1.direction, o1.body
--select count(distinct i.id) as instances --, count(distinct l.id) as leads, count(distinct o.id) as outreaches
from rule_instance i
join outreach o1 on i.id=o1.id_rule_instance
left join "profile" p on p.id=o1.id_profile
join "lead" l on l.id=o1.id_lead
join "outreach" o on l.id=o.id_lead
join rule_instance i2 on (i2.id=o.id_rule_instance and i2.id_rule='1d6f0f56-4cfa-4c0a-b233-7382c09ab9e5') -- 4a (sending connection request)
where i.id_rule='5c1c1038-01a5-4afc-a6db-395f79500b53' -- 4c
order by p.name, l.first_name, l.last_name, o1.create_time
Helping Queries
Delete outreaches generated by a rule:
delete from outreach_seen where id_outreach in (
select o.id
from rule_instance i
left join outreach o on i.id=o.id_rule_instance
where i.id_rule='5c1c1038-01a5-4afc-a6db-395f79500b53'
);
delete from outreach where id in (
select o.id
from rule_instance i
left join outreach o on i.id=o.id_rule_instance
where i.id_rule='5c1c1038-01a5-4afc-a6db-395f79500b53'
);
delete from rule_instance where id_rule='5c1c1038-01a5-4afc-a6db-395f79500b53';
Research Query
After running processes
rule.rb
andplan.rb
.Helping Queries
Delete outreaches generated by a rule: