From dbd92a960ca09ff8ccfe87db82d8266b6704edcf Mon Sep 17 00:00:00 2001 From: Casper Bollen Date: Wed, 3 Jul 2024 19:50:43 +0200 Subject: [PATCH] chore: better initialization procedure --- src/Informedica.GenForm.Lib/DoseRule.fs | 11 ++++++++--- src/Server/Server.fs | 13 ++++++++++++- src/Server/ServerApi.fs | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Informedica.GenForm.Lib/DoseRule.fs b/src/Informedica.GenForm.Lib/DoseRule.fs index ff46c88..bf8b73a 100644 --- a/src/Informedica.GenForm.Lib/DoseRule.fs +++ b/src/Informedica.GenForm.Lib/DoseRule.fs @@ -620,6 +620,7 @@ cannot map {r} let get_ dataUrl = let prods = Product.get () + let warnings = System.Collections.Generic.Dictionary<_, _>() dataUrl |> getData @@ -659,9 +660,13 @@ cannot map {r} |> Array.filter (fun p -> r.GPKs |> Array.exists (String.equalsCapInsens p.GPK)) if filtered |> Array.length = 0 then - ConsoleWriter.writeWarningMessage - $"no products for {gen} {rte}" - true false + let key = $"{gen} {rte}" + if warnings.ContainsKey(key) |> not then + warnings.Add(key, key) + ConsoleWriter.writeWarningMessage + $"no products for {key}" + true false + [| {| r with Products = diff --git a/src/Server/Server.fs b/src/Server/Server.fs index 0355675..44e8f6c 100644 --- a/src/Server/Server.fs +++ b/src/Server/Server.fs @@ -9,6 +9,15 @@ open Shared open Shared.Api +printfn $""" +=== Initialized: === +- Formulary {Formulary.empty |> Formulary.get |> ignore} +- Parenteralia {Parenteralia.empty |> Parenteralia.get |> ignore} +- Scenarios {ScenarioResult.empty |> ScenarioResult.get |> ignore} + +""" + + let tryGetEnv key = match Environment.GetEnvironmentVariable key with | x when String.IsNullOrWhiteSpace x -> None @@ -50,12 +59,14 @@ let application = application { //host_config Env.configureHost } + $""" -Environmental variables +=== Environmental variables === GENPRES_URL_ID={tryGetEnv "GENPRES_URL_ID"} GENPRES_LOG={tryGetEnv "GENPRES_LOG"} GENPRES_PROD={tryGetEnv "GENPRES_PROD"} """ |> printfn "%s" + run application \ No newline at end of file diff --git a/src/Server/ServerApi.fs b/src/Server/ServerApi.fs index 8a91182..83561b0 100644 --- a/src/Server/ServerApi.fs +++ b/src/Server/ServerApi.fs @@ -5,6 +5,8 @@ open Shared.Types open Shared.Api + + /// An implementation of the Shared IServerApi protocol. let serverApi: IServerApi = {