From fd4099a76006d2435c9fba9fc937f8ae362a0770 Mon Sep 17 00:00:00 2001 From: Namekuji Date: Sat, 2 Sep 2023 09:57:32 -0400 Subject: [PATCH] fix: nodeinfo --- .../scylla-migration/cql/1689400417034_timeline/up.cql | 10 ++++++++++ packages/backend/src/server/nodeinfo.ts | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/backend/native-utils/scylla-migration/cql/1689400417034_timeline/up.cql b/packages/backend/native-utils/scylla-migration/cql/1689400417034_timeline/up.cql index 16964e7bcf..78cad49165 100644 --- a/packages/backend/native-utils/scylla-migration/cql/1689400417034_timeline/up.cql +++ b/packages/backend/native-utils/scylla-migration/cql/1689400417034_timeline/up.cql @@ -157,6 +157,16 @@ CREATE MATERIALIZED VIEW local_timeline AS PRIMARY KEY ("createdAtDate", "createdAt", "userId", "userHost", "visibility") WITH CLUSTERING ORDER BY ("createdAt" DESC); +CREATE MATERIALIZED VIEW local_note AS + SELECT "createdAtDate", "createdAt", "userId", "userHost", "visibility" FROM note + WHERE "createdAtDate" IS NOT NULL + AND "createdAt" IS NOT NULL + AND "userId" IS NOT NULL + AND "userHost" = 'local' + AND "visibility" IS NOT NULL + PRIMARY KEY ("createdAtDate", "createdAt", "userId", "userHost", "visibility") + WITH CLUSTERING ORDER BY ("createdAt" DESC); + CREATE MATERIALIZED VIEW score_feed AS SELECT * FROM note WHERE "createdAtDate" IS NOT NULL diff --git a/packages/backend/src/server/nodeinfo.ts b/packages/backend/src/server/nodeinfo.ts index 2d01446522..695d854607 100644 --- a/packages/backend/src/server/nodeinfo.ts +++ b/packages/backend/src/server/nodeinfo.ts @@ -5,6 +5,7 @@ import { Users, Notes } from "@/models/index.js"; import { IsNull, MoreThan } from "typeorm"; import { MAX_NOTE_TEXT_LENGTH, MAX_CAPTION_TEXT_LENGTH } from "@/const.js"; import { Cache } from "@/misc/cache.js"; +import { scyllaClient } from "@/db/scylla"; const router = new Router(); @@ -41,7 +42,11 @@ const nodeinfo2 = async () => { lastActiveDate: MoreThan(new Date(now - 2592000000)), }, }), - Notes.count({ where: { userHost: IsNull() } }), + scyllaClient + ? scyllaClient + .execute("SELECT COUNT(1) FROM local_note") + .then((result) => result.first().get("count") as number) + : Notes.count({ where: { userHost: IsNull() } }), ]); const proxyAccount = meta.proxyAccountId