update
This commit is contained in:
parent
235d7874e5
commit
48420b2e18
|
@ -9,7 +9,9 @@ runTests() {
|
||||||
JQ=${JQ:-jq}
|
JQ=${JQ:-jq}
|
||||||
export JQ_FLAVOR=${JQ_FLAVOR:-jq}
|
export JQ_FLAVOR=${JQ_FLAVOR:-jq}
|
||||||
echo "Running Tests with JQ=${JQ}"
|
echo "Running Tests with JQ=${JQ}"
|
||||||
${JQ} -n -r -L . -L "dropins/${JQ_FLAVOR}" "include \"tests\"; testsMain"
|
${JQ} -nr \
|
||||||
|
-L "$(realpath .)" -L "$(realpath ./lib)" -L "$(realpath ./dropins)/${JQ_FLAVOR}" \
|
||||||
|
"include \"tests\"; testsMain"
|
||||||
}
|
}
|
||||||
|
|
||||||
runTests
|
runTests
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
include "dropins";
|
include "dropins";
|
||||||
include "utils";
|
|
||||||
|
|
||||||
|
import "lib/utilsLib" as utilsLib;
|
||||||
import "lib/stringLib" as stringLib;
|
import "lib/stringLib" as stringLib;
|
||||||
|
import "lib/journalLib" as journalLib;
|
||||||
import "journalLib" as journalLib;
|
|
||||||
|
|
||||||
def formatExperienceTitle:
|
def formatExperienceTitle:
|
||||||
. as $experience |
|
. as $experience |
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import "utils" as utils;
|
import "utilsLib" as utilsLib;
|
||||||
|
|
||||||
def calculateIngestionDose($customUnits):
|
def calculateIngestionDose($customUnits):
|
||||||
. as $ingestion |
|
. as $ingestion |
|
||||||
|
@ -39,11 +39,11 @@ def filterIngestions($substanceFilter; $consumerFilter):
|
||||||
|
|
||||||
def ingestionsSubstanceNames:
|
def ingestionsSubstanceNames:
|
||||||
. as $ingestions |
|
. as $ingestions |
|
||||||
[$ingestions[].substanceName] | utils::orderedUnique;
|
[$ingestions[].substanceName] | utilsLib::orderedUnique;
|
||||||
|
|
||||||
def ingestionsConsumerNames:
|
def ingestionsConsumerNames:
|
||||||
. as $ingestions |
|
. as $ingestions |
|
||||||
[$ingestions[] | ingestionConsumerName] | utils::orderedUnique;
|
[$ingestions[] | ingestionConsumerName] | utilsLib::orderedUnique;
|
||||||
|
|
||||||
def ingestionsByConsumer:
|
def ingestionsByConsumer:
|
||||||
. as $ingestions |
|
. as $ingestions |
|
||||||
|
@ -131,7 +131,7 @@ def filterSortExperiences($customUnits; $substanceFilter; $consumerFilter; $sort
|
||||||
any(index($ingestion.substanceName))
|
any(index($ingestion.substanceName))
|
||||||
)
|
)
|
||||||
) then $experienceData else null end
|
) then $experienceData else null end
|
||||||
] | map(select(. != null));
|
] | objects;
|
||||||
|
|
||||||
def filterByConsumerFilter:
|
def filterByConsumerFilter:
|
||||||
. as $experiencesData |
|
. as $experiencesData |
|
||||||
|
@ -181,14 +181,14 @@ def filterSortExperiences($customUnits; $substanceFilter; $consumerFilter; $sort
|
||||||
elif
|
elif
|
||||||
$sortMethod == "highest-combined-dose"
|
$sortMethod == "highest-combined-dose"
|
||||||
then
|
then
|
||||||
utils::assert($sortOptions.substanceName != null; "substanceName not provided as sortOption") |
|
utilsLib::assert($sortOptions.substanceName != null; "substanceName not provided as sortOption") |
|
||||||
filterBySubstanceAndConsumer |
|
filterBySubstanceAndConsumer |
|
||||||
sort_by(highestCombinedDoseSort, oldToNewSort) |
|
sort_by(highestCombinedDoseSort, oldToNewSort) |
|
||||||
reverse
|
reverse
|
||||||
elif
|
elif
|
||||||
$sortMethod == "highest-dose-for-method"
|
$sortMethod == "highest-dose-for-method"
|
||||||
then
|
then
|
||||||
utils::assert($sortOptions.substanceName != null; "substanceName not provided as sortOption") |
|
utilsLib::assert($sortOptions.substanceName != null; "substanceName not provided as sortOption") |
|
||||||
filterByIngestionMethodForSubstance |
|
filterByIngestionMethodForSubstance |
|
||||||
sort_by(highestMethodDoseSort, oldToNewSort) |
|
sort_by(highestMethodDoseSort, oldToNewSort) |
|
||||||
reverse
|
reverse
|
||||||
|
@ -199,5 +199,5 @@ def filterSortExperiences($customUnits; $substanceFilter; $consumerFilter; $sort
|
||||||
sortFilter;
|
sortFilter;
|
||||||
|
|
||||||
def experienceByTitle($name):
|
def experienceByTitle($name):
|
||||||
utils::assert((. | type) == "array"; "experienceByTitle takes a array of experiences as input") |
|
utilsLib::assert((. | type) == "array"; "experienceByTitle takes a array of experiences as input") |
|
||||||
map(select(.title == $name))[0];
|
map(select(.title == $name))[0];
|
|
@ -4,12 +4,11 @@ import "lib/typeLib" as typeLib;
|
||||||
import "lib/argsLib" as argsLib;
|
import "lib/argsLib" as argsLib;
|
||||||
import "lib/stringLib" as stringLib;
|
import "lib/stringLib" as stringLib;
|
||||||
import "lib/tableLib" as tableLib;
|
import "lib/tableLib" as tableLib;
|
||||||
|
import "lib/utilsLib" as utilsLib;
|
||||||
|
import "lib/journalLib" as journalLib;
|
||||||
|
|
||||||
import "journalLib" as journalLib;
|
|
||||||
import "journalUtils" as journalUtils;
|
import "journalUtils" as journalUtils;
|
||||||
import "types" as types;
|
import "types" as types;
|
||||||
import "utils" as utils;
|
|
||||||
|
|
||||||
|
|
||||||
def printExperienceStats($stats; $substanceFilter; $consumerFilter; $withTitle):
|
def printExperienceStats($stats; $substanceFilter; $consumerFilter; $withTitle):
|
||||||
. as $experience |
|
. as $experience |
|
||||||
|
@ -262,7 +261,7 @@ def main:
|
||||||
$options.sortMethod;
|
$options.sortMethod;
|
||||||
$options.sortOptions
|
$options.sortOptions
|
||||||
) |
|
) |
|
||||||
if ($options.sortFilter != null) then utils::sortFilterFromString($options.sortFilter) end |
|
if ($options.sortFilter != null) then utilsLib::sortFilterFromString($options.sortFilter) end |
|
||||||
printExperiences(
|
printExperiences(
|
||||||
$exportData.customUnits;
|
$exportData.customUnits;
|
||||||
$options.substanceFilter;
|
$options.substanceFilter;
|
||||||
|
|
|
@ -2,6 +2,7 @@ include "dropins";
|
||||||
|
|
||||||
import "lib/testLib" as testLib;
|
import "lib/testLib" as testLib;
|
||||||
import "lib/typeLib" as typeLib;
|
import "lib/typeLib" as typeLib;
|
||||||
|
import "lib/journalLib" as journalLib;
|
||||||
|
|
||||||
import "journalUtils" as journalUtils;
|
import "journalUtils" as journalUtils;
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ def journalUtilsTests:
|
||||||
testLib::expectPassed(testLib::runTest(
|
testLib::expectPassed(testLib::runTest(
|
||||||
"invalid input to experienceByTitle";
|
"invalid input to experienceByTitle";
|
||||||
(
|
(
|
||||||
null | journalUtils::experienceByTitle("Test")
|
null | journalLib::experienceByTitle("Test")
|
||||||
);
|
);
|
||||||
. == "experienceByTitle takes a array of experiences as input";
|
. == "experienceByTitle takes a array of experiences as input";
|
||||||
true
|
true
|
||||||
|
@ -19,7 +20,7 @@ def journalUtilsTests:
|
||||||
testLib::expectPassed(testLib::runTest(
|
testLib::expectPassed(testLib::runTest(
|
||||||
"experience not found";
|
"experience not found";
|
||||||
(
|
(
|
||||||
$exportDataArray[0].experiences | journalUtils::experienceByTitle("Test")
|
$exportDataArray[0].experiences | journalLib::experienceByTitle("Test")
|
||||||
);
|
);
|
||||||
. == null;
|
. == null;
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue