diff --git a/MATScommon b/MATScommon index 19e62fc7ed..c788590257 160000 --- a/MATScommon +++ b/MATScommon @@ -1 +1 @@ -Subproject commit 19e62fc7eda05274b82f6f599fbb406c3e75f0e3 +Subproject commit c7885902576929b6799aecc04f44bd47f62ac4d5 diff --git a/METexpress b/METexpress index c5fa08a4c4..5f4aa93b96 160000 --- a/METexpress +++ b/METexpress @@ -1 +1 @@ -Subproject commit c5fa08a4c4c4e8dbeb2f67087098c1b645cf062c +Subproject commit 5f4aa93b96a57461fef890693370fab322e1146b diff --git a/apps/cb-metar/server/dataFunctions/data_contour.js b/apps/cb-metar/server/dataFunctions/data_contour.js index 88459e2ba8..6e24987729 100644 --- a/apps/cb-metar/server/dataFunctions/data_contour.js +++ b/apps/cb-metar/server/dataFunctions/data_contour.js @@ -73,7 +73,7 @@ dataContour = function (plotParams, plotFunction) { if ( xAxisParam !== "Threshold" && yAxisParam !== "Threshold" && - variableValuesMap[queryVariable][2] + variableValuesMap[queryVariable][1] ) { // threshold is not an axis param and this is a CTC app // so find which threshold was selected @@ -92,7 +92,7 @@ dataContour = function (plotParams, plotFunction) { ] === thresholdStr ); allThresholds = [threshold.replace(/_/g, ".")]; - } else if (variableValuesMap[queryVariable][2]) { + } else if (variableValuesMap[queryVariable][1]) { // threshold is an axis param and this is a CTC app // so catalogue the thresholds now, we'll need to do a separate query for each allThresholds = Object.keys( diff --git a/apps/cb-metar/server/dataFunctions/data_contour_diff.js b/apps/cb-metar/server/dataFunctions/data_contour_diff.js index f247bce6f1..2178447d03 100644 --- a/apps/cb-metar/server/dataFunctions/data_contour_diff.js +++ b/apps/cb-metar/server/dataFunctions/data_contour_diff.js @@ -82,7 +82,7 @@ dataContourDiff = function (plotParams, plotFunction) { if ( xAxisParam !== "Threshold" && yAxisParam !== "Threshold" && - variableValuesMap[queryVariable][2] + variableValuesMap[queryVariable][1] ) { // threshold is not an axis param and this is a CTC app // so find which threshold was selected @@ -101,7 +101,7 @@ dataContourDiff = function (plotParams, plotFunction) { ] === thresholdStr ); allThresholds = [threshold.replace(/_/g, ".")]; - } else if (variableValuesMap[queryVariable][2]) { + } else if (variableValuesMap[queryVariable][1]) { // threshold is an axis param and this is a CTC app // so catalogue the thresholds now, we'll need to do a separate query for each allThresholds = Object.keys( diff --git a/apps/cb-metar/server/dataFunctions/data_dailymodelcycle.js b/apps/cb-metar/server/dataFunctions/data_dailymodelcycle.js index f14d895695..ca85c7e3ec 100644 --- a/apps/cb-metar/server/dataFunctions/data_dailymodelcycle.js +++ b/apps/cb-metar/server/dataFunctions/data_dailymodelcycle.js @@ -75,7 +75,7 @@ dataDailyModelCycle = function (plotParams, plotFunction) { const thresholdStr = curve.threshold; let threshold = ""; - if (variableValuesMap[queryVariable][2]) { + if (variableValuesMap[queryVariable][1]) { threshold = Object.keys( matsCollections.threshold.findOne({ name: "threshold" }).valuesMap[variable] ).find( diff --git a/apps/cb-metar/server/dataFunctions/data_dieoff.js b/apps/cb-metar/server/dataFunctions/data_dieoff.js index fb91b582bf..394f1930d9 100644 --- a/apps/cb-metar/server/dataFunctions/data_dieoff.js +++ b/apps/cb-metar/server/dataFunctions/data_dieoff.js @@ -71,7 +71,7 @@ dataDieoff = function (plotParams, plotFunction) { const thresholdStr = curve.threshold; let threshold = ""; - if (variableValuesMap[queryVariable][2]) { + if (variableValuesMap[queryVariable][1]) { threshold = Object.keys( matsCollections.threshold.findOne({ name: "threshold" }).valuesMap[variable] ).find( diff --git a/apps/cb-metar/server/dataFunctions/data_histogram.js b/apps/cb-metar/server/dataFunctions/data_histogram.js index 8f46cf6622..ddaa8801e9 100644 --- a/apps/cb-metar/server/dataFunctions/data_histogram.js +++ b/apps/cb-metar/server/dataFunctions/data_histogram.js @@ -70,7 +70,7 @@ dataHistogram = function (plotParams, plotFunction) { const thresholdStr = curve.threshold; let threshold = ""; - if (variableValuesMap[queryVariable][2]) { + if (variableValuesMap[queryVariable][1]) { threshold = Object.keys( matsCollections.threshold.findOne({ name: "threshold" }).valuesMap[variable] ).find( diff --git a/apps/cb-metar/server/dataFunctions/data_map.js b/apps/cb-metar/server/dataFunctions/data_map.js index 8640352096..91819132e9 100644 --- a/apps/cb-metar/server/dataFunctions/data_map.js +++ b/apps/cb-metar/server/dataFunctions/data_map.js @@ -62,7 +62,7 @@ dataMap = function (plotParams, plotFunction) { const thresholdStr = curve.threshold; let threshold = ""; - if (variableValuesMap[queryVariable][2]) { + if (variableValuesMap[queryVariable][1]) { threshold = Object.keys( matsCollections.threshold.findOne({ name: "threshold" }).valuesMap[variable] ).find( diff --git a/apps/cb-metar/server/dataFunctions/data_series.js b/apps/cb-metar/server/dataFunctions/data_series.js index 9909aa8034..e044f062d4 100644 --- a/apps/cb-metar/server/dataFunctions/data_series.js +++ b/apps/cb-metar/server/dataFunctions/data_series.js @@ -75,7 +75,7 @@ dataSeries = function (plotParams, plotFunction) { const thresholdStr = curve.threshold; let threshold = ""; - if (variableValuesMap[queryVariable][2]) { + if (variableValuesMap[queryVariable][1]) { threshold = Object.keys( matsCollections.threshold.findOne({ name: "threshold" }).valuesMap[variable] ).find( diff --git a/apps/cb-metar/server/dataFunctions/data_validtime.js b/apps/cb-metar/server/dataFunctions/data_validtime.js index 25b65f5bb1..1811f03b7c 100644 --- a/apps/cb-metar/server/dataFunctions/data_validtime.js +++ b/apps/cb-metar/server/dataFunctions/data_validtime.js @@ -71,7 +71,7 @@ dataValidTime = function (plotParams, plotFunction) { const thresholdStr = curve.threshold; let threshold = ""; - if (variableValuesMap[queryVariable][2]) { + if (variableValuesMap[queryVariable][1]) { threshold = Object.keys( matsCollections.threshold.findOne({ name: "threshold" }).valuesMap[variable] ).find( diff --git a/apps/cb-metar/server/main.js b/apps/cb-metar/server/main.js index c38f9a6c1d..80a3d304c6 100644 --- a/apps/cb-metar/server/main.js +++ b/apps/cb-metar/server/main.js @@ -16,12 +16,8 @@ import { // first field of each value array is sub-variables, second field is metadata document key, // third is boolean for whether or not there are thresholds const variableMetadataDocs = { - Ceiling: [{ "Ceiling (ft)": ["Ceiling", "Ceiling", "ft"] }, "cb-ceiling", true], - Visibility: [ - { "Visibility (mi)": ["Visibility", "Visibility", "mi"] }, - "cb-visibility", - true, - ], + Ceiling: [{ "Ceiling (ft)": ["Ceiling", "Ceiling", "ft"] }, true], + Visibility: [{ "Visibility (mi)": ["Visibility", "Visibility", "mi"] }, true], Surface: [ { "Temperature at 2m (°C)": ["Temperature", "Temperature", "°C"], @@ -32,7 +28,6 @@ const variableMetadataDocs = { "U-Wind at 10m (m/s)": ["WindU", "WindU", "m/s"], "V-Wind at 10m (m/s)": ["WindV", "WindV", "m/s"], }, - "cb-surface", false, ], }; @@ -391,12 +386,12 @@ const doCurveParams = async function () { for (let didx = 0; didx < variables.length; didx += 1) { const variable = variables[didx]; const subVariables = Object.keys(variableMetadataDocs[variable][0]); - const hasThresholds = variableMetadataDocs[variable][2]; + const hasThresholds = variableMetadataDocs[variable][1]; let rows; if (hasThresholds) { // eslint-disable-next-line no-undef const queryStr = cbPool.trfmSQLForDbTarget( - `select raw thresholdDescriptions.${variable.toLowerCase()} from {{vxDBTARGET}} where type="MD" and docType="matsAux" and subset="COMMON" and version="V01"` + `select raw thresholdDescriptions.${variable.toLowerCase()} from {{vxDBTARGET}} use keys "MD:matsAux:COMMON:V01"` ); // eslint-disable-next-line no-undef rows = await cbPool.queryCB(queryStr); @@ -435,18 +430,21 @@ const doCurveParams = async function () { // eslint-disable-next-line no-undef const queryStr = cbPool.trfmSQLForDbTarget( - "select model, displayText, mindate, maxdate, fcstLens, " + - "regions, ifmissing(thresholds,['NA']) as thresholds " + - `from {{vxDBTARGET}} where type="MD" and docType="matsGui" and subset="COMMON" and version="V01" and app="${variableMetadataDocs[variable][1]}" and numrecs>0 ` + - "order by displayCategory, displayOrder" + "select raw models from {{vxDBTARGET}} " + + `USE KEYS "MD:matsGui:${variable.toLowerCase()}:COMMON:V01"` ); // eslint-disable-next-line no-undef - const rows = await cbPool.queryCB(queryStr); - + const [rows] = await cbPool.queryCB(queryStr); if (rows.includes("queryCB ERROR: ")) { // have this local try catch fail properly if the metadata isn't there throw new Error(rows); } + + rows.sort( + (a, b) => + Number(a.displayCategory) - Number(b.displayCategory) || + Number(a.displayOrder) - Number(b.displayOrder) + ); for (let sidx = 0; sidx < subVariables.length; sidx += 1) { const subVariable = subVariables[sidx]; modelOptionsMap[subVariable] = {}; @@ -474,7 +472,7 @@ const doCurveParams = async function () { forecastLengthOptionsMap[subVariable][model] = rows[i].fcstLens.map(String); // we want the full threshold descriptions in thresholdsModelOptionsMap, not just the thresholds - const { thresholds } = rows[i]; + const thresholds = rows[i].thresholds ? rows[i].thresholds : ["NA"]; thresholdsModelOptionsMap[subVariable][model] = thresholds .sort(function (a, b) { return Number(a) - Number(b); @@ -503,7 +501,7 @@ const doCurveParams = async function () { let rows = await cbPool.queryCB( // eslint-disable-next-line no-undef cbPool.trfmSQLForDbTarget( - 'select meta().id, {{vxCOLLECTION}}.* from {{vxDBTARGET}} where type="MD" and docType="station" and version = "V01" and subset="{{vxCOLLECTION}}";' + 'select {{vxCOLLECTION}}.* from {{vxDBTARGET}} where type="MD" and docType="station" and version = "V01" and subset="{{vxCOLLECTION}}";' ) ); if (rows.includes("queryCB ERROR: ")) { @@ -1997,16 +1995,9 @@ Meteor.startup(function () { `${cbConnection.bucket}:${cbConnection.scope}:${cbConnection.collection}`, [ "MD:matsAux:COMMON:V01", - "MD:matsGui:cb-ceiling:RAP_OPS_130:COMMON:V01", - "MD:matsGui:cb-ceiling:HRRR_OPS:COMMON:V01", - "MD:matsGui:cb-visibility:RAP_OPS_130:COMMON:V01", - "MD:matsGui:cb-visibility:HRRR_OPS:COMMON:V01", - "MD:matsGui:cb-surface:HRRR_OPS:COMMON:V01", - "MD:V01:REGION:ALL_HRRR", - "MD:V01:REGION:E_HRRR", - "MD:V01:REGION:E_US", - "MD:V01:REGION:GtLk", - "MD:V01:REGION:W_HRRR", + "MD:matsGui:ceiling:COMMON:V01", + "MD:matsGui:visibility:COMMON:V01", + "MD:matsGui:surface:COMMON:V01", ] ); try {