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