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; }),