fix(news): persist publication requests and retry cache delivery
CI / check (push) Successful in 3m12s
CI / deploy (push) Successful in 1m13s
CI / publish-container (push) Successful in 42s

This commit is contained in:
Simo committed 2026-09-13 18:33:45 +02:00
1 parent c977fe95ba
commit 52f6d1491f
40 files changed
+733 -134

No files matched your search

+4 -25
View File
@@ -2,14 +2,9 @@ import { drainOperationEffects } from "../src/features/operations/worker";
import { drainFurnitureImports } from "../src/lib/services/furni-job-worker";
import "./load-env";
import { Cron } from "croner";
import { and, eq, lt, lte, sql } from "drizzle-orm";
import { lt, sql } from "drizzle-orm";
import { env } from "../src/env";
import {
db,
PasswordReset,
WebsiteArticles,
WebsiteLoginLogs,
} from "../src/lib/db";
import { db, PasswordReset, WebsiteLoginLogs } from "../src/lib/db";
import { logger } from "../src/lib/logger";
import { redis } from "../src/lib/redis";
import {
@@ -23,7 +18,7 @@ import {
diskLevel,
parseDfOutput,
} from "../src/lib/services/disk-usage";
import { invalidateNewsCache } from "../src/lib/services/news-cache";
import { publishDueArticles } from "../src/lib/services/news-scheduler";
import { rcon } from "../src/lib/services/rcon";
function captureWorkerError(err: unknown, context: string): void {
@@ -347,24 +342,8 @@ async function pruneDockerCache(force = false): Promise<void> {
async function publishScheduledArticles(): Promise<void> {
try {
const now = new Date();
const result = await db
.update(WebsiteArticles)
.set({
status: "published",
publishedAt: now,
updatedAt: now,
})
.where(
and(
eq(WebsiteArticles.status, "scheduled"),
lte(WebsiteArticles.publishAt, now),
),
);
const [info] = result;
const published = info.affectedRows ?? 0;
const published = await publishDueArticles();
if (published > 0) {
await invalidateNewsCache();
logger.info(`Published ${published} scheduled article(s)`, {
module: "jobs",
});