can get comment children of an other comment
This commit is contained in:
@@ -7,16 +7,17 @@ create or replace function find_comments_by_parent(
|
||||
) language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select json_agg(t), (select count(id) from "comment" com where com.parents_ids @> array[_parent_id])
|
||||
select json_agg(t), (select count(id) from "comment" c3 where c3.parent_id = _parent_id)
|
||||
into resource, total
|
||||
from (
|
||||
select
|
||||
com.*,
|
||||
(select count(*) from "comment" c2 where c2.parents_ids @> array[com.id]) as children_count,
|
||||
find_reference_by_id(com.target_id, com.target_reference) as target,
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where parent_id = _parent_id
|
||||
order by com.parents_ids nulls first, created_at desc,
|
||||
order by created_at desc,
|
||||
com.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
) as t;
|
||||
|
||||
@@ -7,16 +7,17 @@ create or replace function find_comments_by_target(
|
||||
) language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select json_agg(t), (select count(id) from "comment" com where com.target_id = _target_id)
|
||||
select json_agg(t), (select count(id) from "comment" c3 where c3.parent_id = _target_id)
|
||||
into resource, total
|
||||
from (
|
||||
select
|
||||
com.*,
|
||||
(select count(*) from "comment" c2 where c2.parents_ids @> array[com.id]) as children_count,
|
||||
find_reference_by_id(com.target_id, com.target_reference) as target,
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from "comment" as com
|
||||
where com.target_id = _target_id
|
||||
order by com.parents_ids nulls first, created_at desc,
|
||||
where com.parent_id = _target_id
|
||||
order by created_at desc,
|
||||
com.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
) as t;
|
||||
|
||||
Reference in New Issue
Block a user