diff --git a/package-lock.json b/package-lock.json
index 021f243e..585e9e0a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -76,6 +76,7 @@
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.12",
"@types/jsonwebtoken": "^8.5.8",
+ "@types/lodash-es": "^4.17.6",
"@types/multer": "^1.4.7",
"@types/request-ip": "^0.0.37",
"c8": "^7.11.3",
@@ -982,6 +983,21 @@
"@types/node": "*"
}
},
+ "node_modules/@types/lodash": {
+ "version": "4.14.184",
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.184.tgz",
+ "integrity": "sha512-RoZphVtHbxPZizt4IcILciSWiC6dcn+eZ8oX9IWEYfDMcocdd42f7NPI6fQj+6zI8y4E0L7gu2pcZKLGTRaV9Q==",
+ "dev": true
+ },
+ "node_modules/@types/lodash-es": {
+ "version": "4.17.6",
+ "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz",
+ "integrity": "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==",
+ "dev": true,
+ "dependencies": {
+ "@types/lodash": "*"
+ }
+ },
"node_modules/@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
@@ -10533,6 +10549,21 @@
"@types/node": "*"
}
},
+ "@types/lodash": {
+ "version": "4.14.184",
+ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.184.tgz",
+ "integrity": "sha512-RoZphVtHbxPZizt4IcILciSWiC6dcn+eZ8oX9IWEYfDMcocdd42f7NPI6fQj+6zI8y4E0L7gu2pcZKLGTRaV9Q==",
+ "dev": true
+ },
+ "@types/lodash-es": {
+ "version": "4.17.6",
+ "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.6.tgz",
+ "integrity": "sha512-R+zTeVUKDdfoRxpAryaQNRKk3105Rrgx2CFRClIgRGaqDTdjsm8h6IYA8ir584W3ePzkZfst5xIgDwYrlh9HLg==",
+ "dev": true,
+ "requires": {
+ "@types/lodash": "*"
+ }
+ },
"@types/mime": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-3.0.1.tgz",
diff --git a/package.json b/package.json
index ada4063d..6858347a 100644
--- a/package.json
+++ b/package.json
@@ -120,6 +120,7 @@
"@types/cookie-parser": "^1.4.3",
"@types/cors": "^2.8.12",
"@types/jsonwebtoken": "^8.5.8",
+ "@types/lodash-es": "^4.17.6",
"@types/multer": "^1.4.7",
"@types/request-ip": "^0.0.37",
"c8": "^7.11.3",
diff --git a/src/apps/api/v1/exercises/exercises.controller.js b/src/apps/api/v1/exercises/exercises.controller.js
index 600add9f..9b804be4 100644
--- a/src/apps/api/v1/exercises/exercises.controller.js
+++ b/src/apps/api/v1/exercises/exercises.controller.js
@@ -19,8 +19,8 @@ export async function getExerciseHistory(req, res) {
const { perPage, currentPage } = req.query;
const pagination = {
- perPage,
- currentPage,
+ perPage: perPage ?? null,
+ currentPage: currentPage ?? null,
};
const exercise = await ExercisesQueries.getExerciseHistoryByExerciseId(exercise_id, pagination);
diff --git a/src/apps/api/v1/sessions/sessions.controller.js b/src/apps/api/v1/sessions/sessions.controller.js
index 14d9268b..30789c35 100644
--- a/src/apps/api/v1/sessions/sessions.controller.js
+++ b/src/apps/api/v1/sessions/sessions.controller.js
@@ -87,8 +87,8 @@ export async function getUserSessions(req, res) {
const { perPage, currentPage } = req.query;
const pagination = {
- perPage,
- currentPage,
+ perPage: perPage ?? null,
+ currentPage: currentPage ?? null,
};
const sessions = await SessionQueries.getSessionsByUserId(user_id, pagination);
diff --git a/src/apps/api/v1/variables/variables.controller.js b/src/apps/api/v1/variables/variables.controller.js
index e62e73a0..2d45f7cd 100644
--- a/src/apps/api/v1/variables/variables.controller.js
+++ b/src/apps/api/v1/variables/variables.controller.js
@@ -5,15 +5,38 @@ import path from 'path';
import { marked } from 'marked';
import { calculateE1RM } from '../../../../utils/helpers.js';
+/**
+ * It gets the recovery data for a user
+ * @param req - The request object.
+ * @param res - The response object.
+ * @returns The recovery data for a user.
+ */
export async function getRecovery(req, res) {
+ const { user_id } = req.params;
+ const { perPage, currentPage } = req.query;
+
+ const pagination = {
+ perPage: perPage ?? null,
+ currentPage: currentPage ?? null,
+ };
+
+ const recovery = await VariablesQueries.getRecovery(user_id, pagination);
+
return res.status(StatusCodes.OK).json({
status: 'success',
request_url: req.originalUrl,
message: 'The resource was returned successfully!',
- data: [],
+ data: recovery.data,
+ pagination: recovery.pagination,
});
}
+/**
+ * It reads the `CHANGELOG.md` file and returns the content in HTML format
+ * @param req - The request object.
+ * @param res - The response object.
+ * @returns The changelogs in HTML format.
+ */
export async function getChangelogs(req, res) {
let changelogs = null;
try {
@@ -58,7 +81,8 @@ export async function getWeeklyWeightIn(req, res) {
}
const mapped = [];
- // It's looping through the bodyWeight array and calculating the trend.
+
+ // It's iteration through the bodyWeight array and calculating the trend.
for (let i = 0; i < bodyWeight.length; i++) {
const current = bodyWeight[i];
const previous = bodyWeight[i + 1];
diff --git a/src/apps/api/v1/variables/variables.queries.js b/src/apps/api/v1/variables/variables.queries.js
index 7f17173e..5a94bd69 100644
--- a/src/apps/api/v1/variables/variables.queries.js
+++ b/src/apps/api/v1/variables/variables.queries.js
@@ -57,3 +57,18 @@ export async function recentPrsByUserId(user_id) {
);
return rows;
}
+
+export async function getRecovery(user_id, pagination = { perPage: null, currentPage: null }) {
+ return db
+ .select('v.stress_level', 'v.hours_of_sleep', 'ss.session_rpe', 'v.created_at')
+ .from('variables as v')
+ .innerJoin('sessions as ss', 'ss.id', 'v.session_id')
+ .where({ 'v.user_id': user_id })
+ .andWhere({ 'v.deleted': false })
+ .andWhere({ 'ss.deleted': false })
+ .orderBy('v.created_at', 'desc')
+ .paginate({
+ ...pagination,
+ isLengthAware: true,
+ });
+}
diff --git a/src/apps/api/v1/variables/variables.router.js b/src/apps/api/v1/variables/variables.router.js
index a8615e21..f316ed2a 100644
--- a/src/apps/api/v1/variables/variables.router.js
+++ b/src/apps/api/v1/variables/variables.router.js
@@ -31,9 +31,11 @@ variables.get(
);
/**
- * GET /api/v1/variables/recovery/{user_id}
+ * GET /api/v1/variables/recovery/{user_id}?perPage={perPage}¤tPage={perPage}
* @tags variables
* @summary get recovery tracking information
+ * @param {number} perPage.query.required - the perPage id - application/x-www-form-urlencoded
+ * @param {number} currentPage.query.required - the currentPage id - application/x-www-form-urlencoded
* @param {number} user_id.path.required - the user_id - application/x-www-form-urlencoded
*/
variables.get(
diff --git a/src/apps/api/v1/variables/variables.validation.js b/src/apps/api/v1/variables/variables.validation.js
index bfd26a35..ccf207c9 100644
--- a/src/apps/api/v1/variables/variables.validation.js
+++ b/src/apps/api/v1/variables/variables.validation.js
@@ -1,4 +1,4 @@
-import { check, param, body } from 'express-validator';
+import { check, param, body, query } from 'express-validator';
import * as UsersQueries from '../users/users.queries.js';
/* Validating the user_id. */
@@ -42,6 +42,26 @@ export const getRecentPrs = [
];
export const getRecovery = [
+ query('perPage')
+ .optional()
+ .trim()
+ .notEmpty()
+ .withMessage('perPage must not be empty!')
+ .bail()
+ .isInt()
+ .withMessage('perPage must be an ID!')
+ .bail()
+ .toInt(),
+ query('currentPage')
+ .optional()
+ .trim()
+ .notEmpty()
+ .withMessage('current-page must not be empty!')
+ .bail()
+ .isInt()
+ .withMessage('current-page must be an ID!')
+ .bail()
+ .toInt(),
param('user_id')
.trim()
.notEmpty()
diff --git a/src/apps/ui/pages/dashboard/Exercise.vue b/src/apps/ui/pages/dashboard/Exercise.vue
index 69c3888c..98d28578 100644
--- a/src/apps/ui/pages/dashboard/Exercise.vue
+++ b/src/apps/ui/pages/dashboard/Exercise.vue
@@ -91,7 +91,6 @@ const chartData = computed(() => ({
const { lineChartProps } = useLineChart({
chartData,
});
-
// ----------- chart end
async function getExerciseDetails(currentPage) {
diff --git a/src/apps/ui/pages/dashboard/Profile.vue b/src/apps/ui/pages/dashboard/Profile.vue
index 763d5532..b0b21b40 100644
--- a/src/apps/ui/pages/dashboard/Profile.vue
+++ b/src/apps/ui/pages/dashboard/Profile.vue
@@ -1,11 +1,8 @@
@@ -204,7 +262,7 @@ async function getWeeklyWeightIn() {
Recovery