15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
select p.id as post,
coalesce((select counts.ct from counts where counts.subject = p.id
and counts.kind = 'like'),0)::integer as likes,
coalesce((select counts.ct from counts where counts.subject = p.id
and counts.kind = 'rt' ),0)::integer as rts
from parsav_posts as p
);
create type pg_temp.parsavpg_intern_notice as (
kind smallint,
"when" bigint,
who bigint,
what bigint,
reply bigint,
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
select p.id as post,
coalesce((select counts.ct from counts where counts.subject = p.id
and counts.kind = 'like'),0)::integer as likes,
coalesce((select counts.ct from counts where counts.subject = p.id
and counts.kind = 'rt' ),0)::integer as rts
from parsav_posts as p
);
create type pg_temp.parsavpg_intern_artifact as (
rid bigint,
owner bigint,
"desc" text,
folder text,
mime text
);
create or replace function
pg_temp.parsavpg_translate_artifact(parsav_artifact_claims)
returns pg_temp.parsavpg_intern_artifact as $$
select ($1).rid, ($1).uid, ($1).description, ($1).folder, a.mime
from parsav_artifacts a where
a.id = ($1).rid limit 1
$$ language sql;
create type pg_temp.parsavpg_intern_notice as (
kind smallint,
"when" bigint,
who bigint,
what bigint,
reply bigint,
|