mirror of
https://github.com/versia-pub/server.git
synced 2026-01-26 12:16:01 +01:00
refactor(federation): 🔥 Remove some old SQL queries for Instances
This commit is contained in:
parent
f2b0de779b
commit
38c8ea24a9
|
|
@ -7,6 +7,7 @@ import {
|
|||
type InferInsertModel,
|
||||
type InferSelectModel,
|
||||
type SQL,
|
||||
count,
|
||||
desc,
|
||||
eq,
|
||||
inArray,
|
||||
|
|
@ -234,6 +235,10 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
name:
|
||||
metadata.metadata.nodeName || metadata.metadata.title || "",
|
||||
version: metadata.software.version,
|
||||
description:
|
||||
metadata.metadata.nodeDescription ||
|
||||
metadata.metadata.description ||
|
||||
"",
|
||||
logo: undefined,
|
||||
type: "ServerMetadata",
|
||||
supported_extensions: [],
|
||||
|
|
@ -275,4 +280,14 @@ export class Instance extends BaseInterface<typeof Instances> {
|
|||
protocol: protocol,
|
||||
});
|
||||
}
|
||||
|
||||
static async getCount() {
|
||||
return (
|
||||
await db
|
||||
.select({
|
||||
count: count(),
|
||||
})
|
||||
.from(Instances)
|
||||
)[0].count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { applyConfig, auth } from "@/api";
|
||||
import { jsonResponse, proxyUrl } from "@/response";
|
||||
import { and, count, eq, isNull } from "drizzle-orm";
|
||||
import { and, eq, isNull } from "drizzle-orm";
|
||||
import type { Hono } from "hono";
|
||||
import { db } from "~/drizzle/db";
|
||||
import { Instances, Users } from "~/drizzle/schema";
|
||||
import { Users } from "~/drizzle/schema";
|
||||
import manifest from "~/package.json";
|
||||
import { config } from "~/packages/config-manager";
|
||||
import { Instance } from "~/packages/database-interface/instance";
|
||||
import { Note } from "~/packages/database-interface/note";
|
||||
import { User } from "~/packages/database-interface/user";
|
||||
|
||||
|
|
@ -38,13 +38,7 @@ export default (app: Hono) =>
|
|||
and(isNull(Users.instanceId), eq(Users.isAdmin, true)),
|
||||
);
|
||||
|
||||
const knownDomainsCount = (
|
||||
await db
|
||||
.select({
|
||||
count: count(),
|
||||
})
|
||||
.from(Instances)
|
||||
)[0].count;
|
||||
const knownDomainsCount = Instance.getCount();
|
||||
|
||||
// TODO: fill in more values
|
||||
return jsonResponse({
|
||||
|
|
|
|||
Loading…
Reference in a new issue