Skip to content

Commit

Permalink
remove old MET code
Browse files Browse the repository at this point in the history
we no longer store user's height/weight/etc because we are not calculating calories burned, for that reason the code related to storing user's data or calculating calories is not needed

we will keep MET handling so we can bin activity into high/med/low intensity later

not currently using the "highestMET" calculation code, so commenting that out for now
  • Loading branch information
Abby Wheelis committed Nov 9, 2023
1 parent ec4abff commit 7820646
Showing 1 changed file with 19 additions and 68 deletions.
87 changes: 19 additions & 68 deletions www/js/metrics/metHelper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { getCustomMETs } from './customMetricsHelper';
import { standardMETs } from './metDataset';
import { storageGet, storageSet, storageRemove } from '../plugin/storage';

var highestMET = 0;
var USER_DATA_KEY = 'user-data';
let useCustom = false;

const setUseCustomMET = function () {
export const setUseCustomMET = function () {
useCustom = true;
};

Expand All @@ -18,38 +15,15 @@ const getMETs = function () {
}
};

const set = function (info) {
return storageSet(USER_DATA_KEY, info);
};

const get = function () {
return storageGet(USER_DATA_KEY);
};

const remove = function () {
return storageRemove(USER_DATA_KEY);
};

const between = function (num, min, max) {
return num >= min && num <= max;
};

const getHighestMET = function () {
if (!highestMET) {
var met = getMETs();
let metList = [];
for (var mode in met) {
var rangeList = met[mode];
for (var range in rangeList) {
metList.push(rangeList[range].mets);
}
}
highestMET = Math.max(...metList);
}
return highestMET;
const mpstomph = function (mps) {
return 2.23694 * mps;
};

const getMet = function (mode, speed, defaultIfMissing) {
export const getMet = function (mode, speed, defaultIfMissing) {
if (mode == 'ON_FOOT') {
console.log("getMet() converted 'ON_FOOT' to 'WALKING'");
mode = 'WALKING';
Expand All @@ -69,41 +43,18 @@ const getMet = function (mode, speed, defaultIfMissing) {
}
};

const mpstomph = function (mps) {
return 2.23694 * mps;
};

const lbtokg = function (lb) {
return lb * 0.453592;
};

const fttocm = function (ft) {
return ft * 30.48;
};

const getCorrectedMet = function (met, gender, age, height, heightUnit, weight, weightUnit) {
var height = heightUnit == 0 ? fttocm(height) : height;
var weight = weightUnit == 0 ? lbtokg(weight) : weight;
let calcMet;
if (gender == 1) {
//male
calcMet =
(met * 3.5) /
(((66.473 + 5.0033 * height + 13.7516 * weight - 6.755 * age) / 1440 / 5 / weight) * 1000);
return met;
} else if (gender == 0) {
//female
let met =
(calcMet * 3.5) /
(((655.0955 + 1.8496 * height + 9.5634 * weight - 4.6756 * age) / 1440 / 5 / weight) * 1000);
return calcMet;
}
};

const getuserCalories = function (durationInMin, met) {
return 65 * durationInMin * met;
};

const getCalories = function (weightInKg, durationInMin, met) {
return weightInKg * durationInMin * met;
};
// var highestMET = 0;
// const getHighestMET = function () {
// if (!highestMET) {
// var met = getMETs();
// let metList = [];
// for (var mode in met) {
// var rangeList = met[mode];
// for (var range in rangeList) {
// metList.push(rangeList[range].mets);
// }
// }
// highestMET = Math.max(...metList);
// }
// return highestMET;
// };

0 comments on commit 7820646

Please sign in to comment.