浏览代码

fix(api): update cintas summary ordering to sort by weekId descending

Changed the ordering of cintas summaries from ascending week to descending weekId in both the existing summary retrieval and newly generated summary endpoints. This ensures the most recent weeks appear first in the response.

Also added import ID display to the cintas calendar summary page for better debugging and tracking purposes.
vtugulan 6 月之前
父节点
当前提交
7adba1d7a7
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. 2 2
      app/api/imports/[id]/summary/route.ts
  2. 3 0
      app/cintas-calendar-summary/page.tsx

+ 2 - 2
app/api/imports/[id]/summary/route.ts

@@ -108,7 +108,7 @@ export async function POST(
             // Return existing summary
             const cintasSummaries = await prisma.cintasSummary.findMany({
                 where: { importId },
-                orderBy: { week: 'asc' }
+                orderBy: { weekId: 'desc' }
             });
 
             return NextResponse.json({
@@ -133,7 +133,7 @@ export async function POST(
         // Fetch the newly generated summary
         const cintasSummaries = await prisma.cintasSummary.findMany({
             where: { importId },
-            orderBy: { week: 'asc' }
+            orderBy: { weekId: 'desc' }
         });
 
         return NextResponse.json({

+ 3 - 0
app/cintas-calendar-summary/page.tsx

@@ -316,6 +316,9 @@ export default function CintasCalendarSummaryPage() {
             </CardHeader>
             <CardContent>
               <div className="space-y-4">
+                <p className="text-sm text-muted-foreground">
+                  Import ID: {importRecord?.id}
+                </p>
                 <Button
                   onClick={handleGenerateSummary}
                   disabled={isProcessing}