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