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
@@ -112,38 +112,30 @@ export default async function ShopPage({
|
||||
: t("success.bought")
|
||||
: null;
|
||||
|
||||
// Categories for the filter bar.
|
||||
let categories: ShopCategory[] = [];
|
||||
try {
|
||||
categories = await db
|
||||
// Categories for the filter bar and the article grid are independent —
|
||||
// fetch them concurrently.
|
||||
const [categories, articles] = await Promise.all([
|
||||
db
|
||||
.select({
|
||||
id: WebsiteShopCategories.id,
|
||||
name: WebsiteShopCategories.name,
|
||||
icon: WebsiteShopCategories.icon,
|
||||
})
|
||||
.from(WebsiteShopCategories)
|
||||
.orderBy(asc(WebsiteShopCategories.name));
|
||||
} catch {
|
||||
categories = [];
|
||||
}
|
||||
|
||||
let articles: ShopArticle[] = [];
|
||||
try {
|
||||
if (categoryId) {
|
||||
articles = await db
|
||||
.select(articleSelect)
|
||||
.from(WebsiteShopArticles)
|
||||
.where(eq(WebsiteShopArticles.categoryId, BigInt(categoryId)))
|
||||
.orderBy(asc(WebsiteShopArticles.position));
|
||||
} else {
|
||||
articles = await db
|
||||
.select(articleSelect)
|
||||
.from(WebsiteShopArticles)
|
||||
.orderBy(asc(WebsiteShopArticles.position));
|
||||
}
|
||||
} catch {
|
||||
articles = [];
|
||||
}
|
||||
.orderBy(asc(WebsiteShopCategories.name))
|
||||
.catch((): ShopCategory[] => []),
|
||||
(categoryId
|
||||
? db
|
||||
.select(articleSelect)
|
||||
.from(WebsiteShopArticles)
|
||||
.where(eq(WebsiteShopArticles.categoryId, BigInt(categoryId)))
|
||||
.orderBy(asc(WebsiteShopArticles.position))
|
||||
: db
|
||||
.select(articleSelect)
|
||||
.from(WebsiteShopArticles)
|
||||
.orderBy(asc(WebsiteShopArticles.position))
|
||||
).catch((): ShopArticle[] => []),
|
||||
]);
|
||||
|
||||
const activeCategory = categoryId
|
||||
? categories.find((c) => String(c.id) === categoryId)
|
||||
|
||||
Reference in new issue
Block a user