Fix decay values.
parent
ca7d5956eb
commit
6fe357b54a
|
@ -2,38 +2,40 @@ CREATE OR REPLACE FUNCTION ladderq(date TIMESTAMP) RETURNS integer AS $$
|
||||||
SELECT
|
SELECT
|
||||||
CASE
|
CASE
|
||||||
WHEN date > CURRENT_DATE - INTERVAL '30' DAY THEN 10
|
WHEN date > CURRENT_DATE - INTERVAL '30' DAY THEN 10
|
||||||
WHEN date > CURRENT_DATE - INTERVAL '90' DAY THEN 5
|
WHEN date > CURRENT_DATE - INTERVAL '60' DAY THEN 5
|
||||||
|
WHEN date > CURRENT_DATE - INTERVAL '90' DAY THEN 3
|
||||||
ELSE 1
|
ELSE 1
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE sql STRICT IMMUTABLE;
|
$$ LANGUAGE sql STRICT IMMUTABLE;
|
||||||
|
|
||||||
|
drop materialized view export_dids_ladder;
|
||||||
|
drop materialized view export_replies_ladder;
|
||||||
drop materialized view export_likes_ladder;
|
drop materialized view export_likes_ladder;
|
||||||
|
|
||||||
create materialized view export_likes_ladder
|
create materialized view export_likes_ladder
|
||||||
as select repos.did as ":START_ID",
|
as select repos.did as ":START_ID",
|
||||||
split_part(jsonb_extract_path_text(content, 'subject', 'uri'), '/', 3) as ":END_ID",
|
split_part(jsonb_extract_path_text(content, 'subject', 'uri'), '/', 3) as ":END_ID",
|
||||||
sum(ladderq(records.created_at::TIMESTAMP)) as "count:long"
|
sum(ladderq(records.created_at::TIMESTAMP)) as "count:long"
|
||||||
from records join repos on records.repo = repos.id
|
from records join repos on records.repo = repos.id
|
||||||
where records.collection = 'app.bsky.feed.like'
|
where records.collection = 'app.bsky.feed.like'
|
||||||
and records.created_at > CURRENT_DATE - INTERVAL '240' DAY
|
and records.created_at > CURRENT_DATE - INTERVAL '180' DAY
|
||||||
and repos.did <> split_part(jsonb_extract_path_text(content, 'subject', 'uri'), '/', 3)
|
and repos.did <> split_part(jsonb_extract_path_text(content, 'subject', 'uri'), '/', 3)
|
||||||
group by repos.did, split_part(jsonb_extract_path_text(content, 'subject', 'uri'), '/', 3)
|
group by repos.did, split_part(jsonb_extract_path_text(content, 'subject', 'uri'), '/', 3)
|
||||||
with no data;
|
with no data;
|
||||||
create index export_like_subject_ladder on export_likes_ladder (":END_ID");
|
create index export_like_subject_ladder on export_likes_ladder (":END_ID");
|
||||||
|
|
||||||
drop materialized view export_replies_ladder;
|
|
||||||
create materialized view export_replies_ladder
|
create materialized view export_replies_ladder
|
||||||
as select repos.did as ":START_ID",
|
as select repos.did as ":START_ID",
|
||||||
split_part(jsonb_extract_path_text(content, 'reply', 'parent', 'uri'), '/', 3) as ":END_ID",
|
split_part(jsonb_extract_path_text(content, 'reply', 'parent', 'uri'), '/', 3) as ":END_ID",
|
||||||
sum(ladderq(records.created_at::TIMESTAMP)) as "count:long"
|
sum(ladderq(records.created_at::TIMESTAMP)) as "count:long"
|
||||||
from records join repos on records.repo = repos.id
|
from records join repos on records.repo = repos.id
|
||||||
where records.collection = 'app.bsky.feed.post'
|
where records.collection = 'app.bsky.feed.post'
|
||||||
and records.created_at > CURRENT_DATE - INTERVAL '240' DAY
|
and records.created_at > CURRENT_DATE - INTERVAL '180' DAY
|
||||||
and repos.did <> split_part(jsonb_extract_path_text(content, 'reply', 'parent', 'uri'), '/', 3)
|
and repos.did <> split_part(jsonb_extract_path_text(content, 'reply', 'parent', 'uri'), '/', 3)
|
||||||
group by repos.did, split_part(jsonb_extract_path_text(content, 'reply', 'parent', 'uri'), '/', 3)
|
group by repos.did, split_part(jsonb_extract_path_text(content, 'reply', 'parent', 'uri'), '/', 3)
|
||||||
with no data;
|
with no data;
|
||||||
create index export_reply_subject_ladder on export_replies_ladder (":END_ID");
|
create index export_reply_subject_ladder on export_replies_ladder (":END_ID");
|
||||||
|
|
||||||
drop materialized view export_dids_ladder;
|
|
||||||
create materialized view export_dids_ladder
|
create materialized view export_dids_ladder
|
||||||
as select distinct did as "did:ID" from (
|
as select distinct did as "did:ID" from (
|
||||||
select did from repos
|
select did from repos
|
Loading…
Reference in New Issue