Skip to content

Commit

Permalink
Added global variable comment to cb-metar files
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Nov 16, 2023
1 parent 61245d3 commit 3ede681
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 58 deletions.
14 changes: 7 additions & 7 deletions apps/cb-metar/server/dataFunctions/data_contour.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool, Assets */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -115,7 +117,6 @@ dataContour = function (plotParams, plotFunction) {
);

// SQL template replacements
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_Contour.sql");
queryTemplate = queryTemplate.replace(/{{vxMODEL}}/g, model);
queryTemplate = queryTemplate.replace(/{{vxREGION}}/g, region);
Expand All @@ -129,13 +130,13 @@ dataContour = function (plotParams, plotFunction) {
if (validTimes.length !== 0 && validTimes !== matsTypes.InputTypes.unused) {
queryTemplate = queryTemplate.replace(
/{{vxVALID_TIMES}}/g,
cbPool.trfmListToCSVString(validTimes, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(validTimes, null, false)
);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}

if (xAxisParam !== "Fcst lead time" && yAxisParam !== "Fcst lead time") {
Expand All @@ -146,7 +147,7 @@ dataContour = function (plotParams, plotFunction) {
}
queryTemplate = queryTemplate.replace(/{{vxFCST_LEN}}/g, forecastLength);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxFCST_LEN}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxFCST_LEN}}");
}

let dateString = "";
Expand Down Expand Up @@ -183,12 +184,11 @@ dataContour = function (plotParams, plotFunction) {
const startMoment = moment();
let finishMoment;
try {
// eslint-disable-next-line no-undef
statement = cbPool.trfmSQLForDbTarget(queryTemplateThreshold);

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBContour(
cbPool, // eslint-disable-line no-undef
cbPool,
statement,
appParams,
statisticSelect
Expand Down
14 changes: 7 additions & 7 deletions apps/cb-metar/server/dataFunctions/data_contour_diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool, Assets */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -123,7 +125,6 @@ dataContourDiff = function (plotParams, plotFunction) {
);

// SQL template replacements
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_Contour.sql");
queryTemplate = queryTemplate.replace(/{{vxMODEL}}/g, model);
queryTemplate = queryTemplate.replace(/{{vxREGION}}/g, region);
Expand All @@ -137,13 +138,13 @@ dataContourDiff = function (plotParams, plotFunction) {
if (validTimes.length !== 0 && validTimes !== matsTypes.InputTypes.unused) {
queryTemplate = queryTemplate.replace(
/{{vxVALID_TIMES}}/g,
cbPool.trfmListToCSVString(validTimes, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(validTimes, null, false)
);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}

if (xAxisParam !== "Fcst lead time" && yAxisParam !== "Fcst lead time") {
Expand All @@ -154,7 +155,7 @@ dataContourDiff = function (plotParams, plotFunction) {
}
queryTemplate = queryTemplate.replace(/{{vxFCST_LEN}}/g, forecastLength);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxFCST_LEN}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxFCST_LEN}}");
}

let dateString = "";
Expand Down Expand Up @@ -191,12 +192,11 @@ dataContourDiff = function (plotParams, plotFunction) {
const startMoment = moment();
let finishMoment;
try {
// eslint-disable-next-line no-undef
statement = cbPool.trfmSQLForDbTarget(queryTemplateThreshold);

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBContour(
cbPool, // eslint-disable-line no-undef
cbPool,
statement,
appParams,
statisticSelect
Expand Down
9 changes: 4 additions & 5 deletions apps/cb-metar/server/dataFunctions/data_dailymodelcycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool, Assets */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -102,7 +104,6 @@ dataDailyModelCycle = function (plotParams, plotFunction) {
);

// SQL template replacements
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_DailyModelCycle.sql");
queryTemplate = queryTemplate.replace(/{{vxMODEL}}/g, model);
queryTemplate = queryTemplate.replace(/{{vxREGION}}/g, region);
Expand All @@ -112,7 +113,7 @@ dataDailyModelCycle = function (plotParams, plotFunction) {
queryTemplate = queryTemplate.replace(/{{vxTHRESHOLD}}/g, threshold);
queryTemplate = queryTemplate.replace(
/{{vxUTC_CYCLE_START}}/g,
cbPool.trfmListToCSVString(utcCycleStart, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(utcCycleStart, null, false)
);
} else {
sitesList = curve.sites === undefined ? [] : curve.sites;
Expand Down Expand Up @@ -142,12 +143,10 @@ dataDailyModelCycle = function (plotParams, plotFunction) {
let finishMoment;
try {
if (regionType === "Predefined region") {
// eslint-disable-next-line no-undef
statement = cbPool.trfmSQLForDbTarget(queryTemplate);
} else {
// send to matsMiddle
statement = "Station plot -- no one query.";
// eslint-disable-next-line no-undef
const tss = new matsMiddleDailyModelCycle.MatsMiddleDailyModelCycle(cbPool);
rows = tss.processStationQuery(
variable,
Expand All @@ -162,7 +161,7 @@ dataDailyModelCycle = function (plotParams, plotFunction) {

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBSpecialtyCurve(
cbPool, // eslint-disable-line no-undef
cbPool,
regionType === "Predefined region" ? statement : rows,
appParams,
statisticSelect
Expand Down
15 changes: 5 additions & 10 deletions apps/cb-metar/server/dataFunctions/data_dieoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool, Assets */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -103,13 +105,10 @@ dataDieoff = function (plotParams, plotFunction) {

// SQL template replacements
if (forecastLength === matsTypes.ForecastTypes.dieoff) {
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_DieOff.sql");
} else if (forecastLength === matsTypes.ForecastTypes.utcCycle) {
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_DieOff_UTC.sql");
} else {
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_DieOff_SingleCycle.sql");
singleCycle = fromSecs;
}
Expand All @@ -125,10 +124,9 @@ dataDieoff = function (plotParams, plotFunction) {
if (validTimes.length !== 0 && validTimes !== matsTypes.InputTypes.unused) {
queryTemplate = queryTemplate.replace(
/{{vxVALID_TIMES}}/g,
cbPool.trfmListToCSVString(validTimes, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(validTimes, null, false)
);
} else {
// eslint-disable-next-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(
queryTemplate,
"{{vxVALID_TIMES}}"
Expand All @@ -143,10 +141,9 @@ dataDieoff = function (plotParams, plotFunction) {
) {
queryTemplate = queryTemplate.replace(
/{{vxUTC_CYCLE_START}}/g,
cbPool.trfmListToCSVString(utcCycleStart, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(utcCycleStart, null, false)
);
} else {
// eslint-disable-next-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(
queryTemplate,
"{{vxUTC_CYCLE_START}}"
Expand Down Expand Up @@ -182,12 +179,10 @@ dataDieoff = function (plotParams, plotFunction) {
let finishMoment;
try {
if (regionType === "Predefined region") {
// eslint-disable-next-line no-undef
statement = cbPool.trfmSQLForDbTarget(queryTemplate);
} else {
// send to matsMiddle
statement = "Station plot -- no one query.";
// eslint-disable-next-line no-undef
const tss = new matsMiddleDieoff.MatsMiddleDieoff(cbPool);
rows = tss.processStationQuery(
variable,
Expand All @@ -205,7 +200,7 @@ dataDieoff = function (plotParams, plotFunction) {

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBSpecialtyCurve(
cbPool, // eslint-disable-line no-undef
cbPool,
regionType === "Predefined region" ? statement : rows,
appParams,
statisticSelect
Expand Down
10 changes: 5 additions & 5 deletions apps/cb-metar/server/dataFunctions/data_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool, Assets */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -97,7 +99,6 @@ dataHistogram = function (plotParams, plotFunction) {
);

// SQL template replacements
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_Histogram.sql");
queryTemplate = queryTemplate.replace(/{{vxMODEL}}/g, model);
queryTemplate = queryTemplate.replace(/{{vxREGION}}/g, region);
Expand All @@ -110,10 +111,10 @@ dataHistogram = function (plotParams, plotFunction) {
if (validTimes.length !== 0 && validTimes !== matsTypes.InputTypes.unused) {
queryTemplate = queryTemplate.replace(
/{{vxVALID_TIMES}}/g,
cbPool.trfmListToCSVString(validTimes, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(validTimes, null, false)
);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}

// axisKey is used to determine which axis a curve should use.
Expand All @@ -135,12 +136,11 @@ dataHistogram = function (plotParams, plotFunction) {
const startMoment = moment();
let finishMoment;
try {
// eslint-disable-next-line no-undef
statement = cbPool.trfmSQLForDbTarget(queryTemplate);

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBSpecialtyCurve(
cbPool, // eslint-disable-line no-undef
cbPool,
statement,
appParams,
statisticSelect
Expand Down
5 changes: 3 additions & 2 deletions apps/cb-metar/server/dataFunctions/data_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -97,7 +99,6 @@ dataMap = function (plotParams, plotFunction) {
try {
// send to matsMiddle
statement = "Station plot -- no one query.";
// eslint-disable-next-line no-undef
const tss = new matsMiddleMap.MatsMiddleMap(cbPool);
rows = tss.processStationQuery(
variable,
Expand All @@ -112,7 +113,7 @@ dataMap = function (plotParams, plotFunction) {

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBMapCTC(
cbPool, // eslint-disable-line no-undef
cbPool,
rows,
model,
statisticSelect,
Expand Down
14 changes: 7 additions & 7 deletions apps/cb-metar/server/dataFunctions/data_perfDiagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Copyright (c) 2021 Colorado State University and Regents of the University of Colorado. All rights reserved.
*/

/* global cbPool, Assets */

import {
matsCollections,
matsTypes,
Expand Down Expand Up @@ -114,7 +116,6 @@ dataPerformanceDiagram = function (plotParams, plotFunction) {
);

// SQL template replacements
// eslint-disable-next-line no-undef
queryTemplate = Assets.getText("sqlTemplates/tmpl_PerformanceDiagram.sql");
queryTemplate = queryTemplate.replace(/{{vxMODEL}}/g, model);
queryTemplate = queryTemplate.replace(/{{vxREGION}}/g, region);
Expand All @@ -127,13 +128,13 @@ dataPerformanceDiagram = function (plotParams, plotFunction) {
if (validTimes.length !== 0 && validTimes !== matsTypes.InputTypes.unused) {
queryTemplate = queryTemplate.replace(
/{{vxVALID_TIMES}}/g,
cbPool.trfmListToCSVString(validTimes, null, false) // eslint-disable-line no-undef
cbPool.trfmListToCSVString(validTimes, null, false)
);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxVALID_TIMES}}");
}

if (binParam !== "Fcst lead time") {
Expand All @@ -144,7 +145,7 @@ dataPerformanceDiagram = function (plotParams, plotFunction) {
}
queryTemplate = queryTemplate.replace(/{{vxFCST_LEN}}/g, forecastLength);
} else {
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxFCST_LEN}}"); // eslint-disable-line no-undef
queryTemplate = cbPool.trfmSQLRemoveClause(queryTemplate, "{{vxFCST_LEN}}");
}

let dateString = "";
Expand Down Expand Up @@ -180,12 +181,11 @@ dataPerformanceDiagram = function (plotParams, plotFunction) {
const startMoment = moment();
let finishMoment;
try {
// eslint-disable-next-line no-undef
statement = cbPool.trfmSQLForDbTarget(queryTemplateThreshold);

// send the query statement to the query function
queryResult = matsDataQueryUtils.queryDBPerformanceDiagram(
cbPool, // eslint-disable-line no-undef
cbPool,
statement,
appParams
);
Expand Down
Loading

0 comments on commit 3ede681

Please sign in to comment.