feat: dashboard

This commit is contained in:
2026-06-05 01:25:16 +02:00
parent 147858de2f
commit 2f6c52e73c
73 changed files with 3490 additions and 1061 deletions

View File

@@ -0,0 +1,16 @@
import { DataSource } from 'typeorm';
import { ServerEntity } from '../../../entities';
import { rowToServer } from '../../mappers';
import { loadServerRelationsMap } from '../../relations';
import { loadMembershipCounts, rankTrendingServers } from './server-ranking.util';
const DEFAULT_LIMIT = 12;
export async function handleGetTrendingServers(dataSource: DataSource, limit = DEFAULT_LIMIT) {
const rows = await dataSource.getRepository(ServerEntity).find({ where: { isPrivate: 0 } });
const counts = await loadMembershipCounts(dataSource, rows.map((row) => row.id));
const ranked = rankTrendingServers(rows, counts, limit);
const relationsByServerId = await loadServerRelationsMap(dataSource, ranked.map((row) => row.id));
return ranked.map((row) => rowToServer(row, relationsByServerId.get(row.id)));
}