Add performance optimizations and component refactors
- Cache read-heavy public API routes via redisCache (leaderboard, values, shop, articles, photos, guilds, teams, staff, users, home, radio, badges) - Add single-flight and bounded-memory cache layer with unit tests - Parallelize independent DB queries on search, rares, shop, staff, polls and profile pages - Push radio points leaderboard aggregation to SQL with a LIMIT - Split studio-client and import-furni-client into focused modules - Clean up next.config.ts
This commit is contained in:
1 parent
54f2bc5e0c
commit
f285a7cd98
42 files changed
+1616
-1205
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { desc, eq, inArray } from "drizzle-orm";
|
||||
import { apiJson } from "@/lib/api";
|
||||
import { db, User, UsersCurrency } from "@/lib/db";
|
||||
import { apiCacheKey, redisCache } from "@/lib/redis-cache";
|
||||
|
||||
// Public REST API — leaderboard. Mirrors src/app/leaderboard/page.tsx.
|
||||
// AtomCMS-faithful currency type ids (see UsersCurrency):
|
||||
@@ -75,11 +76,15 @@ export async function GET(req: Request) {
|
||||
? requested
|
||||
: "credits";
|
||||
|
||||
const rows =
|
||||
type === "credits"
|
||||
? await loadCreditsRows()
|
||||
: // eslint-disable-next-line security/detect-object-injection -- type validated to "diamonds"|"duckets"
|
||||
await loadCurrencyRows(CURRENCY_TYPE[type]);
|
||||
const rows = await redisCache(
|
||||
apiCacheKey(`leaderboard:${type}`),
|
||||
60,
|
||||
async () =>
|
||||
type === "credits"
|
||||
? await loadCreditsRows()
|
||||
: // eslint-disable-next-line security/detect-object-injection -- type validated to "diamonds"|"duckets"
|
||||
await loadCurrencyRows(CURRENCY_TYPE[type]),
|
||||
);
|
||||
|
||||
return apiJson({ type, data: rows }, { status: 200 });
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user