Implement comment constitution

fix bugs
This commit is contained in:
2019-08-28 23:32:43 +02:00
parent 33f4992b5e
commit 4c2da6ab71
17 changed files with 277 additions and 86 deletions

View File

@@ -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')

View File

@@ -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);