【BigInt】の検索結果
こっちのほうが読みやすい? (やってることは一緒)
// Scalaで階乗
object Main extends App{
def factorial(x: Int, buffer: BigInt): BigInt = {
if(x <= 1) {
buffer
} else {
factorial(x-1, x*buffer)
}
}
println(factorial(100, 1))
}
RE: https://mi.tsujigoya.net/notes/a9gn66p46r
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
そして制約が欠けてる、、、
以上が起きてるdb↓
misskey=# \d "__chart_day__per_user_notes"
Table "public.__chart_day__per_user_notes"
Column | Type | Collation | Nullable | Default
-------------------+------------------------+-----------+----------+---------------------------------------------------------
id | integer | | not null | nextval('__chart_day__per_user_notes_id_seq'::regclass)
date | integer | | not null |
group | character varying(128) | | not null |
___total | integer | | not null | '0'::bigint
___inc | smallint | | not null | '0'::bigint
___dec | smallint | | not null | '0'::bigint
___diffs_normal | smallint | | not null | '0'::bigint
___diffs_reply | smallint | | not null | '0'::bigint
___diffs_renote | smallint | | not null | '0'::bigint
___diffs_withFile | smallint | | not null | '0'::smallint
Indexes:
"PK_58bab6b6d3ad9310cbc7460fd28" PRIMARY KEY, btree (id)
正常なdb↓misskey=# \d "__chart_day__per_user_notes"
Table "public.__chart_day__per_user_notes"
Column | Type | Collation | Nullable | Default
-------------------+------------------------+-----------+----------+---------------------------------------------------------
id | integer | | not null | nextval('__chart_day__per_user_notes_id_seq'::regclass)
date | integer | | not null |
group | character varying(128) | | not null |
___total | integer | | not null | '0'::bigint
___inc | smallint | | not null | '0'::bigint
___dec | smallint | | not null | '0'::bigint
___diffs_normal | smallint | | not null | '0'::bigint
___diffs_reply | smallint | | not null | '0'::bigint
___diffs_renote | smallint | | not null | '0'::bigint
___diffs_withFile | smallint | | not null | '0'::smallint
Indexes:
"PK_58bab6b6d3ad9310cbc7460fd28" PRIMARY KEY, btree (id)
"IDX_c5545d4b31cdc684034e33b81c" UNIQUE, btree (date, "group")
"UQ_c5545d4b31cdc684034e33b81c3" UNIQUE CONSTRAINT, btree (date, "group")