From 85fcc8be9664e60da0ce6815d07eaf3f517a1e37 Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:24:42 +0100 Subject: [PATCH] small migration and error fix --- .../migration.sql.diff | 11 ----------- template/app/src/analytics/operations.ts | 5 ++++- 2 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 opensaas-sh/app_diff/migrations/20241031103046_remove_checkout_session_id/migration.sql.diff diff --git a/opensaas-sh/app_diff/migrations/20241031103046_remove_checkout_session_id/migration.sql.diff b/opensaas-sh/app_diff/migrations/20241031103046_remove_checkout_session_id/migration.sql.diff deleted file mode 100644 index e50b0027..00000000 --- a/opensaas-sh/app_diff/migrations/20241031103046_remove_checkout_session_id/migration.sql.diff +++ /dev/null @@ -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"; diff --git a/template/app/src/analytics/operations.ts b/template/app/src/analytics/operations.ts index 86479a76..e9ed8669 100644 --- a/template/app/src/analytics/operations.ts +++ b/template/app/src/analytics/operations.ts @@ -15,7 +15,7 @@ export const getDailyStats: GetDailyStats = 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 = async (_args sources: true, }, }); + if (!dailyStats) { + throw new HttpError(204, 'No daily stats generated yet.'); + } const weeklyStats = await context.entities.DailyStats.findMany({ orderBy: {