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 e50b002..0000000 --- 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 86479a7..e9ed866 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: {