1 create or replace function community_aggregates_activity(i text)
2 returns table(count_ bigint, community_id_ integer)
8 select count(*), community_id
10 select c.creator_id, p.community_id from comment c
11 inner join post p on c.post_id = p.id
12 where c.published > ('now'::timestamp - i::interval)
14 select p.creator_id, p.community_id from post p
15 where p.published > ('now'::timestamp - i::interval)
17 group by community_id;
21 create or replace function site_aggregates_activity(i text) returns integer
30 select c.creator_id from comment c
31 inner join person u on c.creator_id = u.id
32 where c.published > ('now'::timestamp - i::interval)
35 select p.creator_id from post p
36 inner join person u on p.creator_id = u.id
37 where p.published > ('now'::timestamp - i::interval)