Fediverse search system

Fediver

beta version

【CREATE OR REPLACE FUNCTION】の検索結果


CREATE OR REPLACE FUNCTION public.timestamp_to_aid(t timestamptz) RETURNS text AS $$
DECLARE
    time_part text;
    num bigint;
BEGIN
	num := extract(epoch from t) * 1000 + mod(extract(millisecond from t),1000)::integer - 946684800000;
    time_part := '00';
    FOR i IN 1..8 LOOP
		time_part := substring('0123456789abcdefghijklmnopqrstuvwxyz', (1 + mod(num, 36))::integer, 1) || time_part;
		num := num / 36;
    END LOOP;
    RETURN time_part;
END;
$$ LANGUAGE plpgsql;

select n.* from "note" n
where
	not exists (select 1 from note reply where reply."replyId" = n.id)
	and not exists (select 1 from note renote where renote."renoteId" = n.id)
	and not exists (select 1 from note_favorite nf where nf."noteId" = n.id )
	and n."clippedCount" =0
	and id < timestamp_to_aid(current_date - 56)
order by id desc;
timestamp_to_aid 関数は、かなりまっちゃてぃーさんの書いた式を参考にしてその逆関数にしてる
https://nanasi-apps.xyz/Misskey-oldremotenote