From 0dfb7fab726f48b0f912645a529d5da608f800f5 Mon Sep 17 00:00:00 2001 From: chaos Date: Sat, 9 Nov 2024 15:58:44 +0000 Subject: [PATCH] update --- tool/journalUtils.jq | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tool/journalUtils.jq b/tool/journalUtils.jq index a5adec3..2eb0fc2 100644 --- a/tool/journalUtils.jq +++ b/tool/journalUtils.jq @@ -9,6 +9,16 @@ def formatExperienceTitle: . as $experience | "\"\(.title)\": \(.creationDate / 1000 | strftime("%d-%m-%Y"))"; +def formatDose($dose; $unit; $isEstimate; $standardDeviation): + if $dose == null then + "Unknown" + else + (if $isEstimate then "~" else "" end) as $estimate | + (if $standardDeviation != null then "±\($standardDeviation)" else "" end) as $standardDeviation | + + "\($estimate)\($dose | numberLib::round(2))\($standardDeviation) \($unit)" + end; + def formatIngestionDose($customUnits): . as $ingestion | (. | journalLib::ingestionDose($customUnits)) as $dose | @@ -18,14 +28,13 @@ def formatIngestionDose($customUnits): if $ingestion.dose == null then "Unknown" elif $customUnit == null then - if $ingestion.isDoseAnEstimate then "~" else "" end + - "\($dose | numberLib::round(2))" + - if $standardDeviation != null then - "±\($standardDeviation)" - else "" end + - " \($unit)" + formatDose($dose; $unit; $ingestion.isDoseAnEstimate; $standardDeviation) else - "\($dose) \($unit) (\($customUnit.dose) \($unit) * \($ingestion.dose) \($customUnit.unit))" + formatDose($dose; $unit; $ingestion.isDoseAnEstimate; $standardDeviation) + + " (" + + formatDose($customUnit.dose; $unit; $customUnit.isEstimate; $customUnit.estimatedDoseStandardDeviation) + + " * " + + formatDose($ingestion.dose; $customUnit.unit; $ingestion.isDoseAnEstimate; $ingestion.estimatedDoseStandardDeviation) end; def formatIngestionTime: