Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 47 additions & 77 deletions meteor_packages/mats-common/.npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ export const checkMetaDataRefresh = async function () {
// private method for getting pagenated data
// a newPageIndex of -1000 means get all the data (used for export)
// a newPageIndex of -2000 means get just the last page
export const getPagenatedData = function (rky, p, np) {
export const getPagenatedData = async function (rky, p, np) {
if (Meteor.isServer) {
const key = rky;
const myPageIndex = p;
const newPageIndex = np;
let rawReturn;

try {
const result = matsCache.getResult(key);
const result = await matsCache.getResult(key);
rawReturn = result === undefined ? undefined : result.result; // getResult structure is {key:something, result:resultObject}
} catch (e) {
console.log("getPagenatedData: Error - ", e);
Expand Down Expand Up @@ -211,14 +211,14 @@ export const getPagenatedData = function (rky, p, np) {
};

// private method for getting pagenated results and flattening them in order to be appropriate for text display.
export const getFlattenedResultData = function (rk, p, np) {
export const getFlattenedResultData = async function (rk, p, np) {
if (Meteor.isServer) {
try {
const r = rk;
const thisP = p;
const thisNP = np;
// get the pagenated data
const result = getPagenatedData(r, thisP, thisNP);
const result = await getPagenatedData(r, thisP, thisNP);
// find the type
const { plotTypes } = result.basis.plotParams;
const plotType = _.invert(plotTypes).true;
Expand Down
20 changes: 10 additions & 10 deletions meteor_packages/mats-common/imports/startup/api/matsMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const saveResultData = async function (result) {
delete storedResult.data[ci].x_epoch; // we only needed this as an index for downsampling
}
}
matsCache.storeResult(key, {
await matsCache.storeResult(key, {
key,
result: storedResult,
}); // lifespan is handled by lowDb (internally) in matscache
Expand Down Expand Up @@ -502,7 +502,7 @@ const getGraphData = new ValidatedMethod({
plotType: {
type: String,
},
expireKey: {
removeKey: {
type: Boolean,
},
}).validator(),
Expand All @@ -516,10 +516,10 @@ const getGraphData = new ValidatedMethod({
try {
const hash = require("object-hash");
const key = hash(params.plotParams);
if (process.env.NODE_ENV === "development" || params.expireKey) {
matsCache.expireKey(key);
if (process.env.NODE_ENV === "development" || params.removeKey) {
await matsCache.removeKey(key);
}
const results = matsCache.getResult(key);
const results = await matsCache.getResult(key);
if (results === undefined) {
// results aren't in the cache - need to process data routine
const graphData = await global[dataFunction](params.plotParams);
Expand Down Expand Up @@ -554,7 +554,7 @@ const getGraphData = new ValidatedMethod({
} else {
ret = results; // {key:someKey, result:resultObject}
// refresh expire time. The only way to perform a refresh on matsCache is to re-save the result.
matsCache.storeResult(results.key, results);
await matsCache.storeResult(results.key, results);
}
return ret;
} catch (dataFunctionError) {
Expand Down Expand Up @@ -596,7 +596,7 @@ const getGraphDataByKey = new ValidatedMethod({
if (dsResults !== undefined) {
ret = dsResults;
} else {
ret = matsCache.getResult(key); // {key:someKey, result:resultObject}
ret = await matsCache.getResult(key); // {key:someKey, result:resultObject}
}
const sizeof = require("object-sizeof");
console.log("getGraphDataByKey results size is ", sizeof(dsResults));
Expand Down Expand Up @@ -715,14 +715,14 @@ const getPlotResult = new ValidatedMethod({
type: Number,
},
}).validator(),
run(params) {
async run(params) {
if (Meteor.isServer) {
const rKey = params.resultKey;
const pi = params.pageIndex;
const npi = params.newPageIndex;
let ret = {};
try {
ret = getFlattenedResultData(rKey, pi, npi);
ret = await getFlattenedResultData(rKey, pi, npi);
} catch (e) {
console.log(e);
}
Expand Down Expand Up @@ -1213,7 +1213,7 @@ const resetApp = async function (appRef) {
for (let ai = 0; ai < global.appSpecificResetRoutines.length; ai += 1) {
await global.appSpecificResetRoutines[ai]();
}
matsCache.clear();
await matsCache.clear();
}
};

Expand Down
Loading
Loading