small migration and error fix

This commit is contained in:
vincanger 2024-11-19 10:24:42 +01:00
parent a8654e3d64
commit 85fcc8be96
2 changed files with 4 additions and 12 deletions

View File

@ -1,11 +0,0 @@
--- template/app/migrations/20241031103046_remove_checkout_session_id/migration.sql
+++ opensaas-sh/app/migrations/20241031103046_remove_checkout_session_id/migration.sql
@@ -0,0 +1,8 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `checkoutSessionId` on the `User` table. All the data in the column will be lost.
+
+*/
+-- AlterTable
+ALTER TABLE "User" DROP COLUMN "checkoutSessionId";

View File

@ -15,7 +15,7 @@ export const getDailyStats: GetDailyStats<void, DailyStatsValues> = async (_args
if (!context.user?.isAdmin) {
throw new HttpError(401);
}
const dailyStats = await context.entities.DailyStats.findFirstOrThrow({
const dailyStats = await context.entities.DailyStats.findFirst({
orderBy: {
date: 'desc',
},
@ -23,6 +23,9 @@ export const getDailyStats: GetDailyStats<void, DailyStatsValues> = async (_args
sources: true,
},
});
if (!dailyStats) {
throw new HttpError(204, 'No daily stats generated yet.');
}
const weeklyStats = await context.entities.DailyStats.findMany({
orderBy: {