fix(news): restore publication flow and deduplicate dashboard friends
This commit is contained in:
1 parent
ef94646d60
commit
9b0ea2fb16
22 files changed
+638
-195
No files matched your search
@@ -3,7 +3,9 @@ import { env } from "@/env";
|
||||
import { apiJson } from "@/lib/api";
|
||||
import { db, User, WebsiteArticles } from "@/lib/db";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { apiCacheKey, cacheSafe, redisCache } from "@/lib/redis-cache";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { apiCacheKey, cacheSafe } from "@/lib/redis-cache";
|
||||
import { cacheNews } from "@/lib/services/news-cache";
|
||||
|
||||
/**
|
||||
* GET /api/home — combined landing payload: the latest 4 website_articles and
|
||||
@@ -12,7 +14,7 @@ import { apiCacheKey, cacheSafe, redisCache } from "@/lib/redis-cache";
|
||||
*/
|
||||
export async function GET(_req: Request) {
|
||||
try {
|
||||
const data = await redisCache(apiCacheKey("home"), 15, async () => {
|
||||
const data = await cacheNews(apiCacheKey("home"), 15_000, async () => {
|
||||
const [articles, onlineRows, hotelName] = await Promise.all([
|
||||
db
|
||||
.select({
|
||||
@@ -45,7 +47,8 @@ export async function GET(_req: Request) {
|
||||
});
|
||||
});
|
||||
return apiJson(data);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
logger.error("Public news query failed", { module: "news", error });
|
||||
return apiJson(
|
||||
{ articles: [], online: 0, hotelName: env.HOTEL_NAME },
|
||||
{ status: 200 },
|
||||
|
||||
Reference in new issue
Block a user