Implement comment constitution
fix bugs
This commit is contained in:
@@ -1,17 +1,13 @@
|
||||
create or replace function edit_comment(reference regclass, _id uuid, _content text) returns void
|
||||
create or replace function edit_comment(_id uuid, _content text) returns void
|
||||
language plpgsql as
|
||||
$$
|
||||
begin
|
||||
if reference = 'article'::regclass then
|
||||
update comment_on_article c set
|
||||
update comment c set
|
||||
"content" = _content
|
||||
where c.id = _id;
|
||||
elseif reference = 'constitution'::regclass then
|
||||
update comment_on_constitution c set
|
||||
"content" = _content
|
||||
where c.id = _id;
|
||||
end if;
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- drop function if exists edit_comment(regclass, uuid, text);
|
||||
-- drop function if exists edit_comment(regclass, uuid, text);
|
||||
|
||||
-- select edit_comment('b0422e48-687f-bea7-b45f-b6b301246e97', 'plop4')
|
||||
@@ -1,27 +0,0 @@
|
||||
create or replace function find_comments_article_by_citizen(
|
||||
_created_by_id uuid,
|
||||
"limit" int default 50,
|
||||
"offset" int default 0,
|
||||
out resource json,
|
||||
out total int
|
||||
) language plpgsql as
|
||||
$$
|
||||
begin
|
||||
select json_agg(t), (select count(id) from comment where target_reference = 'article'::regclass)
|
||||
into resource, total
|
||||
from (
|
||||
select
|
||||
com.*,
|
||||
find_article_by_id(com.target_id) as target,
|
||||
find_citizen_by_id(com.created_by_id) as created_by
|
||||
from comment as com
|
||||
where created_by_id = _created_by_id
|
||||
and target_reference = 'article'::regclass
|
||||
order by created_at desc,
|
||||
com.created_at desc
|
||||
limit "limit" offset "offset"
|
||||
) as t;
|
||||
end;
|
||||
$$;
|
||||
|
||||
-- drop function if exists find_comments_article_by_citizen(uuid, int, int);
|
||||
Reference in New Issue
Block a user