Revert "Merge pull request 'Complete Housekeeping migration and /ase cutover' (#52) from codex/housekeeping-complete into main"
CI / check (push) Successful in 27s
CI / release (push) Skipped
CI / deploy (push) Successful in 43s

This reverts commit 488b6e57c4, reversing
changes made to b506b4499a.
This commit is contained in:
Simo committed 2026-08-30 21:31:34 +02:00
1 parent 488b6e57c4
commit b1ddda66ff
802 files changed
+61370 -76659

No files matched your search

+33 -54
View File
@@ -1,40 +1,41 @@
import "server-only";
import { count, desc, eq } from "drizzle-orm";
import type { OnlineUser } from "@/components/admin/dashboard";
import { db, User } from "@/lib/db";
interface OpsOnlineUserRow {
readonly id: number;
readonly username: string;
readonly look: string;
readonly lastOnline: number;
}
/** Shared online roster used by CommandoCentrum (and linked from other ops hubs). */
export async function fetchOpsOnlineUsers(
limit = 40,
): Promise<{ count: number; users: OnlineUser[] }> {
const [countRow, onlineUsersRaw] = await Promise.all([
db
.select({ total: count() })
.from(User)
.where(eq(User.online, "1"))
.then((rows) => rows[0]?.total ?? 0)
.catch(() => 0),
db
.select({
id: User.id,
username: User.username,
look: User.look,
lastOnline: User.lastOnline,
})
.from(User)
.where(eq(User.online, "1"))
.orderBy(desc(User.lastOnline))
.limit(limit)
.then((rows) => rows)
.catch(
() =>
[] as Array<{
id: number;
username: string;
look: string;
lastOnline: number;
}>,
),
]);
function loadOnlineCount(): Promise<number> {
return db
.select({ total: count() })
.from(User)
.where(eq(User.online, "1"))
.then((rows) => rows[0]?.total ?? 0);
}
function loadOnlineRows(limit: number): Promise<OpsOnlineUserRow[]> {
return db
.select({
id: User.id,
username: User.username,
look: User.look,
lastOnline: User.lastOnline,
})
.from(User)
.where(eq(User.online, "1"))
.orderBy(desc(User.lastOnline))
.limit(limit)
.then((rows) => rows);
}
function onlineRoster(countRow: number, onlineUsersRaw: OpsOnlineUserRow[]) {
const users: OnlineUser[] = onlineUsersRaw.map((u) => ({
id: u.id,
username: u.username,
@@ -46,25 +47,3 @@ function onlineRoster(countRow: number, onlineUsersRaw: OpsOnlineUserRow[]) {
return { count: countRow, users };
}
/** Fail-aware roster for guarded System workflows. */
export async function fetchOpsOnlineUsersStrict(
limit = 40,
): Promise<{ count: number; users: OnlineUser[] }> {
const [countRow, onlineUsersRaw] = await Promise.all([
loadOnlineCount(),
loadOnlineRows(limit),
]);
return onlineRoster(countRow, onlineUsersRaw);
}
/** Shared tolerant roster used by the legacy CommandoCentrum. */
export async function fetchOpsOnlineUsers(
limit = 40,
): Promise<{ count: number; users: OnlineUser[] }> {
const [countRow, onlineUsersRaw] = await Promise.all([
loadOnlineCount().catch(() => 0),
loadOnlineRows(limit).catch(() => []),
]);
return onlineRoster(countRow, onlineUsersRaw);
}