From c3d3c4500e8116489455579969151de1bbcb3af3 Mon Sep 17 00:00:00 2001 From: DeeCee03 Date: Sat, 6 Jun 2026 17:39:17 +0200 Subject: [PATCH] fix(dashboard): "Gestern im Team" war immer leer (ENTWICKLUN-13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Vortags-Feed verlangte published_at IS NOT NULL, gesetzt nur vom Cron publish-day-entries. Auf Prod ist dieser Cron nicht eingeplant (keine crontab/ kein Scheduler) → published_at blieb bei allen echten Reflexionen null → Feed immer leer (auf Dev sah's gut aus, weil der Seed published_at setzt). Feed jetzt vom Cron entkoppelt: zeigt volle Reflexionen mit Datum < heute (heutige bleiben privat bis morgen), sortiert nach Datum/Reflexionszeit. Gilt für dashboard.overview.feed und dayEntry.feed. Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/api/src/routers/dashboard.ts | 8 +++++--- apps/api/src/routers/day-entry.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/api/src/routers/dashboard.ts b/apps/api/src/routers/dashboard.ts index be39fea..a7a4061 100644 --- a/apps/api/src/routers/dashboard.ts +++ b/apps/api/src/routers/dashboard.ts @@ -1,4 +1,4 @@ -import { and, eq, ne, isNotNull, isNull, count, desc } from 'drizzle-orm'; +import { and, eq, ne, isNull, lt, count, desc } from 'drizzle-orm'; import { area, project, blocker, dayEntry, user, risk, type Area, type Project } from '@cockpit/db'; import { router, protectedProcedure } from '../trpc.js'; import { todayIso, previousWerktag } from '../lib/werktag.js'; @@ -30,8 +30,10 @@ export const dashboardRouter = router({ }) .from(dayEntry) .innerJoin(user, eq(user.id, dayEntry.userId)) - .where(and(isNotNull(dayEntry.publishedAt), eq(dayEntry.status, 'full'))) - .orderBy(desc(dayEntry.publishedAt)) + // „Gestern im Team": volle Reflexionen vor heute (heutige bleiben privat + // bis morgen). Unabhängig vom publish-Cron. + .where(and(lt(dayEntry.date, todayDate), eq(dayEntry.status, 'full'))) + .orderBy(desc(dayEntry.date), desc(dayEntry.reflectedAt)) .limit(50), ctx.db .select({ diff --git a/apps/api/src/routers/day-entry.ts b/apps/api/src/routers/day-entry.ts index e64b97f..8491308 100644 --- a/apps/api/src/routers/day-entry.ts +++ b/apps/api/src/routers/day-entry.ts @@ -1,5 +1,5 @@ import { TRPCError } from '@trpc/server'; -import { and, eq, isNull, isNotNull, lt, asc, desc, inArray } from 'drizzle-orm'; +import { and, eq, isNull, lt, asc, desc, inArray } from 'drizzle-orm'; import { dayEntry, todo, blocker, type Todo } from '@cockpit/db'; import { DayEntrySchemas } from '@cockpit/shared'; import { router, protectedProcedure } from '../trpc.js'; @@ -371,11 +371,14 @@ export const dayEntryRouter = router({ * Nutzbar in Story 3.4 (Dashboard-Feed). */ feed: protectedProcedure.query(async ({ ctx }) => { + // Volle Reflexionen vor heute (heutige bleiben privat bis morgen) — + // unabhängig vom publish-Cron. + const today = todayIso(); const entries = await ctx.db .select() .from(dayEntry) - .where(isNotNull(dayEntry.publishedAt)) - .orderBy(desc(dayEntry.publishedAt)) + .where(and(lt(dayEntry.date, today), eq(dayEntry.status, 'full'))) + .orderBy(desc(dayEntry.date), desc(dayEntry.reflectedAt)) .limit(50); return entries; }),