Compare commits

...

2 Commits

Author SHA1 Message Date
0c29135bad nessa routes 2026-07-13 14:11:46 -04:00
52174c94dc lineage analytics 2026-07-13 13:26:08 -04:00
4 changed files with 2080 additions and 556 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,7 @@ import { infillRouter } from "./routers/infill";
import { accountRouter } from "./routers/account"; import { accountRouter } from "./routers/account";
import { downloadsRouter } from "./routers/downloads"; import { downloadsRouter } from "./routers/downloads";
import { nessaDbRouter } from "./routers/nessa"; import { nessaDbRouter } from "./routers/nessa";
import { nessaCommunityRouter } from "./routers/nessa-community";
import { appleNotificationsRouter } from "./routers/apple-notifications"; import { appleNotificationsRouter } from "./routers/apple-notifications";
import { createTRPCRouter, createTRPCContext, t } from "./utils"; import { createTRPCRouter, createTRPCContext, t } from "./utils";
import type { H3Event } from "h3"; import type { H3Event } from "h3";
@@ -32,6 +33,9 @@ export const appRouter = createTRPCRouter({
account: accountRouter, account: accountRouter,
downloads: downloadsRouter, downloads: downloadsRouter,
nessaDb: nessaDbRouter, nessaDb: nessaDbRouter,
// Community features (clubs, challenges, social feed) — ported from the
// standalone nessa-api Express prototype. Exposes nessa.community.*.
nessa: createTRPCRouter({ community: nessaCommunityRouter }),
appleNotifications: appleNotificationsRouter appleNotifications: appleNotificationsRouter
}); });

View File

@@ -1,4 +1,4 @@
import { createTRPCRouter, publicProcedure } from "../../utils"; import { createTRPCRouter, publicProcedure, adminProcedure } from "../../utils";
import { z } from "zod"; import { z } from "zod";
import { LineageConnectionFactory } from "~/server/utils"; import { LineageConnectionFactory } from "~/server/utils";
import { env } from "~/env/server"; import { env } from "~/env/server";
@@ -92,4 +92,42 @@ export const lineageMiscRouter = createTRPCRouter({
offlineSecret: publicProcedure.query(() => { offlineSecret: publicProcedure.query(() => {
return { secret: env.LINEAGE_OFFLINE_SERIALIZATION_SECRET }; return { secret: env.LINEAGE_OFFLINE_SERIALIZATION_SECRET };
}), }),
getLineageStats: adminProcedure.query(async () => {
const conn = LineageConnectionFactory();
try {
const res = await conn.execute({
sql: `SELECT * FROM Analytics`,
args: [],
});
const rows = res.rows.map((row: any) => ({
playerID: row.playerID as string,
dungeonProgression: safeJsonParse(row.dungeonProgression),
playerClass: row.playerClass as string,
spellCount: row.spellCount as number,
proficiencies: safeJsonParse(row.proficiencies),
jobs: safeJsonParse(row.jobs),
resistanceTable: safeJsonParse(row.resistanceTable),
damageTable: safeJsonParse(row.damageTable),
}));
return { success: true, players: rows };
} catch (e) {
console.error("Failed to fetch lineage analytics:", e);
return { success: false, players: [] };
}
}),
}); });
function safeJsonParse(val: unknown): unknown {
if (typeof val === "string") {
try {
return JSON.parse(val);
} catch {
return val;
}
}
return val;
}

File diff suppressed because it is too large Load Diff