Compare commits
2 Commits
7dc5166e90
...
0c29135bad
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c29135bad | |||
| 52174c94dc |
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
1258
src/server/api/routers/nessa-community.ts
Normal file
1258
src/server/api/routers/nessa-community.ts
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user