From 1f350e22b9276b8d1a3f9d774a124111eaf2a163 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Mon, 3 Jun 2024 18:55:52 +0530 Subject: [PATCH] Fix create operations and env booleans --- src/cron/automatedDailyRounds.ts | 4 ++-- src/utils/configs.ts | 19 +++++++++---------- src/utils/dailyRoundUtils.ts | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/cron/automatedDailyRounds.ts b/src/cron/automatedDailyRounds.ts index 08fefc0..fbdefe0 100644 --- a/src/cron/automatedDailyRounds.ts +++ b/src/cron/automatedDailyRounds.ts @@ -144,7 +144,7 @@ export async function fileAutomatedDailyRound( .catch((error: AxiosError) => error.response); if (saveDailyRound) { - prisma.dailyRound.create({ + await prisma.dailyRound.create({ data: { assetExternalId: assetId, status: response?.statusText ?? "FAILED", @@ -366,7 +366,7 @@ export async function automatedDailyRounds() { (weight! + 1) : accuracy; - prisma.vitalsStat.create({ + await prisma.vitalsStat.create({ data: { imageId: _id, vitalsFromImage: JSON.parse(JSON.stringify(vitals)), diff --git a/src/utils/configs.ts b/src/utils/configs.ts index a5a4772..b3c99f1 100644 --- a/src/utils/configs.ts +++ b/src/utils/configs.ts @@ -1,6 +1,5 @@ import * as dotenv from "dotenv"; - dotenv.config(); export const nodeEnv = process.env.NODE_ENV ?? "development"; @@ -20,8 +19,10 @@ export const sentryTracesSampleRate = parseFloat( process.env.SENTRY_SAMPLE_RATE ?? "0.01", ); -export const saveDailyRound = Boolean(process.env.SAVE_DAILY_ROUND ?? "true"); -export const saveVitalsStat = Boolean(process.env.SAVE_VITALS_STAT ?? "true"); +export const saveDailyRound = + (process.env.SAVE_DAILY_ROUND || "true") === "true"; +export const saveVitalsStat = + (process.env.SAVE_VITALS_STAT || "true") === "true"; export const s3Provider = process.env.S3_PROVIDER ?? "AWS"; export const s3Endpoint = @@ -34,16 +35,14 @@ export const s3BucketName = process.env.S3_BUCKET_NAME; export const s3AccessKeyId = process.env.S3_ACCESS_KEY_ID; export const s3SecretAccessKey = process.env.S3_SECRET_ACCESS_KEY; -export const s3DumpVitalsStat = Boolean( - process.env.S3_DUMP_VITALS_STAT ?? "false", -); -export const deleteVitalsStatOnDump = Boolean( - process.env.DELETE_VITALS_STAT_ON_DUMP ?? "false", -); +export const s3DumpVitalsStat = + (process.env.S3_DUMP_VITALS_STAT || "false") === "true"; +export const deleteVitalsStatOnDump = + (process.env.DELETE_VITALS_STAT_ON_DUMP || "false") === "true"; export const openaiApiKey = process.env.OPENAI_API_KEY ?? ""; export const openaiEndpoint = process.env.OPENAI_ENDPOINT ?? ""; export const openaiApiVersion = process.env.OPENAI_API_VERSION ?? "2024-02-01"; export const openaiVisionModel = process.env.OPENAI_VISION_MODEL ?? "vision-preview"; -export const openaiUseAzure = openaiEndpoint.includes("azure.com"); \ No newline at end of file +export const openaiUseAzure = openaiEndpoint.includes("azure.com"); diff --git a/src/utils/dailyRoundUtils.ts b/src/utils/dailyRoundUtils.ts index ad17ba8..9c49067 100644 --- a/src/utils/dailyRoundUtils.ts +++ b/src/utils/dailyRoundUtils.ts @@ -52,7 +52,7 @@ export const getPatientId = async (assetExternalId: string) => { // }; export const getBedById = async (bedId: string) => { - return prisma.bed.findFirst({ + return await prisma.bed.findFirst({ where: { externalId: bedId, deleted: false,