Skip to content

Commit

Permalink
Linted the rest of the server routines except for middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
mollybsmith-noaa committed Aug 14, 2024
1 parent 22ac537 commit a7f944f
Show file tree
Hide file tree
Showing 12 changed files with 1,704 additions and 1,386 deletions.
14 changes: 7 additions & 7 deletions meteor_packages/mats-common/imports/startup/api/matsMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -1493,14 +1493,14 @@ const _getFlattenedResultData = function (rk, p, np) {
}
var stats = {};
stats.label = data[ci].label;
stats.mean = data[ci].glob_stats.d_mean;
stats.mean = data[ci].glob_stats.dMean;
stats["standard deviation"] = data[ci].glob_stats.sd;
stats.n = data[ci].glob_stats.n_good;
stats.n = data[ci].glob_stats.nGood;
if (
plotType === matsTypes.PlotTypes.timeSeries ||
plotType === matsTypes.PlotTypes.profile
) {
stats["standard error"] = data[ci].glob_stats.stde_betsy;
stats["standard error"] = data[ci].glob_stats.stdeBetsy;
stats.lag1 = data[ci].glob_stats.lag1;
}
stats.minimum = data[ci].glob_stats.minVal;
Expand Down Expand Up @@ -1541,10 +1541,10 @@ const _getFlattenedResultData = function (rk, p, np) {
plotType === matsTypes.PlotTypes.timeSeries ||
plotType === matsTypes.PlotTypes.profile
) {
curveDataElement["std error"] = data[ci].stats[cdi].stde_betsy;
curveDataElement["std error"] = data[ci].stats[cdi].stdeBetsy;
curveDataElement.lag1 = data[ci].stats[cdi].lag1;
}
curveDataElement.n = data[ci].stats[cdi].n_good;
curveDataElement.n = data[ci].stats[cdi].nGood;
}
curveData.push(curveDataElement);
}
Expand Down Expand Up @@ -1774,9 +1774,9 @@ const _getFlattenedResultData = function (rk, p, np) {
}
var stats = {};
stats.label = data[ci].label;
stats.mean = data[ci].glob_stats.d_mean;
stats.mean = data[ci].glob_stats.dMean;
stats["standard deviation"] = data[ci].glob_stats.sd;
stats.n = data[ci].glob_stats.n_good;
stats.n = data[ci].glob_stats.nGood;
stats.minimum = data[ci].glob_stats.minVal;
stats.maximum = data[ci].glob_stats.maxVal;
returnData.stats[data[ci].label] = stats;
Expand Down
17 changes: 12 additions & 5 deletions meteor_packages/mats-common/imports/startup/server/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,40 @@
*/

import { Meteor } from "meteor/meteor";
import { matsCollections } from "meteor/randyp:mats-common";

/* eslint-disable global-require */

let getResult;
let storeResult;
let clear;
let expireKey;

if (Meteor.isServer) {
const Results = require("node-file-cache").create({
file: "fileCache",
life: 8 * 3600,
});
var getResult = function (key) {
getResult = function (key) {
// console.log('asked to get result from cache for key:', key);
const result = Results.get(key);
return result === null ? undefined : result;
};
var storeResult = function (key, result) {
storeResult = function (key, result) {
// console.log('asked to set result in cache for app: ',process.env.PWD, ' key:', key);
Results.set(key, result);
// console.log('set result in cache for app: ', process.env.PWD, 'key:', key);
};
var clear = function () {
clear = function () {
// console.log('asked to clear result cache');
Results.clear();
};
var expireKey = function (key) {
expireKey = function (key) {
// console.log('asked to clear result cache for key ', key);
Results.expire(key);
};
}

// eslint-disable-next-line no-undef
export default matsCache = {
getResult,
storeResult,
Expand Down
35 changes: 17 additions & 18 deletions meteor_packages/mats-common/imports/startup/server/cb_utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class CBUtilities {
this.conn = undefined;
}

/* eslint-disable global-require */
/* eslint-disable no-console */
/* eslint-disable class-methods-use-this */

// The app doesn't directly require couchbase, but it does need to know about the DurabilityLevel enum
// Follow the pattern below to define other enums that are needed by the app.
// see https://docs.couchbase.com/sdk-api/couchbase-node-client/enums/DurabilityLevel.html
Expand Down Expand Up @@ -63,20 +67,16 @@ class CBUtilities {
};

upsertCB = async (key, doc, options = {}) => {
const couchbase = require("couchbase");
try {
const conn = await this.getConnection();
let result;
result = await conn.collection.upsert(key, doc, options);
return result;
return await conn.collection.upsert(key, doc, options);
} catch (err) {
console.log("upsertCB ERROR: ", err);
throw new Error(`upsertCB ERROR: ${err}`);
}
};

removeCB = async (key) => {
const couchbase = require("couchbase");
try {
const conn = await this.getConnection();
const result = await conn.collection.remove(key);
Expand All @@ -88,7 +88,6 @@ class CBUtilities {
};

getCB = async (key) => {
const couchbase = require("couchbase");
try {
const conn = await this.getConnection();
const result = await conn.collection.get(key);
Expand All @@ -100,7 +99,6 @@ class CBUtilities {
};

queryCB = async (statement) => {
const couchbase = require("couchbase");
const Future = require("fibers/future");
try {
let result;
Expand Down Expand Up @@ -132,20 +130,20 @@ class CBUtilities {
};

searchStationsByBoundingBox = async (
topleft_lon,
topleft_lat,
bottomright_lon,
bottomright_lat
topLeftLon,
topLeftLat,
bottomRightLon,
bottomRightLat
) => {
const couchbase = require("couchbase");
const index = "station_geo";
try {
const conn = await this.getConnection();
const geoBoundingBoxQuery = couchbase.SearchQuery.geoBoundingBox(
topleft_lon,
topleft_lat,
bottomright_lon,
bottomright_lat
topLeftLon,
topLeftLat,
bottomRightLon,
bottomRightLat
);
const results = await conn.cluster.searchQuery(index, geoBoundingBoxQuery, {
fields: ["*"],
Expand Down Expand Up @@ -188,17 +186,18 @@ class CBUtilities {
trfmSQLRemoveClause = (sqlstr, clauseFragment) => {
const lines = sqlstr.split("\n");
let rv = "";
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes(clauseFragment) == false) {
for (let i = 0; i < lines.length; i += 1) {
if (!lines[i].includes(clauseFragment)) {
rv = `${rv + lines[i]}\n`;
}
}
return rv;
};
}

test = async () => {};
const test = async () => {};

// eslint-disable-next-line no-undef
export default matsCouchbaseUtils = {
CBUtilities,
test,
Expand Down
Loading

0 comments on commit a7f944f

Please sign in to comment.