Hozifa Elgherbawy commited on
Commit
fa482ac
·
unverified ·
2 Parent(s): 0e757fa 75f3dfb

Merge pull request #97 from Modarb-Ai-Trainer:Images

Browse files
src/modules/users/modules/meal-plans/services/meal-plans.service.ts CHANGED
@@ -54,7 +54,7 @@ export class MealPlansService extends CrudService(MealPlan) {
54
 
55
  const mealPlan = await this.create({
56
  aiGenerated: true,
57
- image: "https://placehold.co/300x400",
58
  description: `This AI-generated meal plan is designed specifically for you, considering your personal fitness goal of ${user.preferences.fitness_goal}.
59
  Created on ${todayDate} at ${currentTime}.${milliseconds}, this plan is tailored to provide a balanced and nutritious diet that supports your workout frequency of ${user.preferences.workout_frequency} times per week.
60
  Whether you prefer working out on ${user.preferences.preferred_days.join(", ")}, at ${user.preferences.workout_place}, or using ${user.preferences.preferred_equipment.join(", ")}, this meal plan will help you achieve your health and fitness goals. Enjoy a variety of delicious and nutritious meals selected just for you.`,
 
54
 
55
  const mealPlan = await this.create({
56
  aiGenerated: true,
57
+ image: `https://t4.ftcdn.net/jpg/01/81/12/37/360_F_181123726_invADRiRZle7YWLYfkEHz0mUfWH60kVZ.jpg`,
58
  description: `This AI-generated meal plan is designed specifically for you, considering your personal fitness goal of ${user.preferences.fitness_goal}.
59
  Created on ${todayDate} at ${currentTime}.${milliseconds}, this plan is tailored to provide a balanced and nutritious diet that supports your workout frequency of ${user.preferences.workout_frequency} times per week.
60
  Whether you prefer working out on ${user.preferences.preferred_days.join(", ")}, at ${user.preferences.workout_place}, or using ${user.preferences.preferred_equipment.join(", ")}, this meal plan will help you achieve your health and fitness goals. Enjoy a variety of delicious and nutritious meals selected just for you.`,
src/modules/users/modules/workouts/services/workouts.service.ts CHANGED
@@ -70,7 +70,7 @@ export class WorkoutService extends CrudService(Workout) {
70
  description: `This AI-generated workout plan, created on ${todayDate} at ${currentTime}.${milliseconds}, is tailored for your ${user.fitness_level.toLowerCase()} fitness level and ${user.preferences.fitness_goal.toLowerCase()} goal. It is designed to be performed ${user.preferences.workout_place === WorkoutPlace.GYM ? "at the gym" : "at home"} using your preferred equipment.`,
71
  type: "Equipment Diversity",
72
  created_by: user._id,
73
- image: "https://placehold.co/300x400",
74
  fitness_level: user.fitness_level,
75
  fitness_goal: user.preferences.fitness_goal,
76
  place: place,
@@ -83,7 +83,7 @@ export class WorkoutService extends CrudService(Workout) {
83
  days: week.map((day, j) => ({
84
  day_number: j + 1,
85
  total_number_exercises: day.length,
86
- day_type: "full_body", // #TODO: Change this
87
  exercises: day.map((e) => exercises.find((ex) => ex.name === e.name)?._id),
88
  })),
89
  })),
 
70
  description: `This AI-generated workout plan, created on ${todayDate} at ${currentTime}.${milliseconds}, is tailored for your ${user.fitness_level.toLowerCase()} fitness level and ${user.preferences.fitness_goal.toLowerCase()} goal. It is designed to be performed ${user.preferences.workout_place === WorkoutPlace.GYM ? "at the gym" : "at home"} using your preferred equipment.`,
71
  type: "Equipment Diversity",
72
  created_by: user._id,
73
+ image: `https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRvEFvhT6PV5u-yCaY5lJRtySenHFAJquCb7BHcmuMwW5hSVVoWYH0DU2eCXoKn6yMYqH0&usqp=CAU`,
74
  fitness_level: user.fitness_level,
75
  fitness_goal: user.preferences.fitness_goal,
76
  place: place,
 
83
  days: week.map((day, j) => ({
84
  day_number: j + 1,
85
  total_number_exercises: day.length,
86
+ day_type: "full body", // #TODO: Change this
87
  exercises: day.map((e) => exercises.find((ex) => ex.name === e.name)?._id),
88
  })),
89
  })),
src/resources/exercises.csv CHANGED
The diff for this file is too large to render. See raw diff
 
src/seeder/helpers/db-store.ts CHANGED
@@ -4,8 +4,8 @@ import { IMealJson } from './load-meals-dataset';
4
  export const dbStore: {
5
  dbConnected: boolean;
6
  excerisesDataset: IExerciseCSV[];
7
- musclesDataset: IExerciseCSV['target'][];
8
- equipmentsDataset: IExerciseCSV['equipment'][];
9
  mealsDataset: IMealJson[];
10
  ingredientsNames: string[];
11
  } = {
 
4
  export const dbStore: {
5
  dbConnected: boolean;
6
  excerisesDataset: IExerciseCSV[];
7
+ musclesDataset: ({ name: IExerciseCSV['target'], image: IExerciseCSV["target_url"] })[];
8
+ equipmentsDataset: ({ name: IExerciseCSV['equipment'], image: IExerciseCSV["equipment_url"] })[];
9
  mealsDataset: IMealJson[];
10
  ingredientsNames: string[];
11
  } = {
src/seeder/helpers/load-exercises-dataset.ts CHANGED
@@ -23,6 +23,9 @@ export interface IExerciseCSV {
23
  sets: number;
24
  instructions: string;
25
  benefits: string;
 
 
 
26
  }
27
 
28
 
 
23
  sets: number;
24
  instructions: string;
25
  benefits: string;
26
+ target_url: string;
27
+ equipment_url: string;
28
+ gif_url: string;
29
  }
30
 
31
 
src/seeder/seed.ts CHANGED
@@ -16,8 +16,18 @@ import { loadMealsDataset } from "./helpers/load-meals-dataset";
16
  const loadDatasets = async () => {
17
  const exercisesDataset = await loadExercisesDataset();
18
  const mealsDataset = loadMealsDataset();
19
- const musclesDataset = Array.from(new Set(exercisesDataset.map((exercise) => exercise.target)));
20
- const equipmentsDataset = Array.from(new Set(exercisesDataset.map((exercise) => exercise.equipment)));
 
 
 
 
 
 
 
 
 
 
21
  const ingredientsArrays = mealsDataset.map(m => m.RecipeIngredientParts);
22
  const ingredientsNames = Array.from(new Set(ingredientsArrays.flat()))
23
 
 
16
  const loadDatasets = async () => {
17
  const exercisesDataset = await loadExercisesDataset();
18
  const mealsDataset = loadMealsDataset();
19
+ let musclesDataset = exercisesDataset.map((exercise) => ({ name: exercise.target, image: exercise.target_url }));
20
+ musclesDataset = musclesDataset.filter((value, index, self) =>
21
+ index === self.findIndex((t) => (
22
+ t.name === value.name
23
+ ))
24
+ )
25
+ let equipmentsDataset = exercisesDataset.map((exercise) => ({ name: exercise.equipment, image: exercise.equipment_url }));
26
+ equipmentsDataset = equipmentsDataset.filter((value, index, self) =>
27
+ index === self.findIndex((t) => (
28
+ t.name === value.name
29
+ ))
30
+ )
31
  const ingredientsArrays = mealsDataset.map(m => m.RecipeIngredientParts);
32
  const ingredientsNames = Array.from(new Set(ingredientsArrays.flat()))
33
 
src/seeder/seeders/003-muscles.seeder.ts CHANGED
@@ -4,6 +4,6 @@ import { seederWrapper } from "seeder/helpers/seeder-wrapper";
4
 
5
  export default seederWrapper(Muscle, async () => {
6
  await Promise.all(dbStore.musclesDataset.map(async function (m) {
7
- return Muscle.create({ name: m, image: `https://placehold.co/600x400`, isDeleted: false})
8
  }))
9
  })
 
4
 
5
  export default seederWrapper(Muscle, async () => {
6
  await Promise.all(dbStore.musclesDataset.map(async function (m) {
7
+ return Muscle.create({ name: m.name, image: m.image, isDeleted: false})
8
  }))
9
  })
src/seeder/seeders/004-equipments.seeder.ts CHANGED
@@ -3,6 +3,6 @@ import { dbStore } from "seeder/helpers/db-store";
3
  import { seederWrapper } from "seeder/helpers/seeder-wrapper";
4
 
5
  export default seederWrapper(Equipment, async () => { await Promise.all(dbStore.equipmentsDataset.map(async function (e) {
6
- return Equipment.create({ name: e, image: `https://placehold.co/600x400`, isDeleted: false})
7
  }))
8
  })
 
3
  import { seederWrapper } from "seeder/helpers/seeder-wrapper";
4
 
5
  export default seederWrapper(Equipment, async () => { await Promise.all(dbStore.equipmentsDataset.map(async function (e) {
6
+ return Equipment.create({ name: e.name, image: e.image, isDeleted: false})
7
  }))
8
  })
src/seeder/seeders/005-exercises.seeder.ts CHANGED
@@ -60,10 +60,10 @@ export default seederWrapper(Exercise, async () => {
60
  secondary: (await Muscle.findOne({ name: e.target }).exec())._id,
61
  },
62
  equipments: [(await Equipment.findOne({ name: e.equipment }).exec())._id],
63
- coverImage: "https://placehold.co/600x400",
64
  media: {
65
  type: 'image',
66
- url: "https://placehold.co/600x400",
67
  },
68
  isDeleted: false,
69
  } satisfies IExercise;
 
60
  secondary: (await Muscle.findOne({ name: e.target }).exec())._id,
61
  },
62
  equipments: [(await Equipment.findOne({ name: e.equipment }).exec())._id],
63
+ coverImage: e.gif_url,
64
  media: {
65
  type: 'image',
66
+ url: e.gif_url,
67
  },
68
  isDeleted: false,
69
  } satisfies IExercise;
src/seeder/seeders/006-workout.seeder.ts CHANGED
@@ -28,7 +28,7 @@ export default seederWrapper(Workout, async () => {
28
  name: `Workout - ${i}`,
29
  description: `Workout - ${i} description`,
30
  type: 'Equipment Diversity',
31
- image: `https://placehold.co/300x400`,
32
  fitness_level: [FitnessLevel.BEGINNER, FitnessLevel.INTERMEDIATE, FitnessLevel.ADVANCED][i % 3],
33
  fitness_goal: [FitnessGoal.LOSE_WEIGHT, FitnessGoal.GAIN_MUSCLE, FitnessGoal.GET_FITTER][i % 3],
34
  place: [Place.GYM, Place.HOME][i % 2],
 
28
  name: `Workout - ${i}`,
29
  description: `Workout - ${i} description`,
30
  type: 'Equipment Diversity',
31
+ image: `https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRvEFvhT6PV5u-yCaY5lJRtySenHFAJquCb7BHcmuMwW5hSVVoWYH0DU2eCXoKn6yMYqH0&usqp=CAU`,
32
  fitness_level: [FitnessLevel.BEGINNER, FitnessLevel.INTERMEDIATE, FitnessLevel.ADVANCED][i % 3],
33
  fitness_goal: [FitnessGoal.LOSE_WEIGHT, FitnessGoal.GAIN_MUSCLE, FitnessGoal.GET_FITTER][i % 3],
34
  place: [Place.GYM, Place.HOME][i % 2],
src/seeder/seeders/007-myWorkout.seeder.ts CHANGED
@@ -11,6 +11,7 @@ export default seederWrapper(UserRegisteredWorkout, async () => {
11
  fitness_level: user.fitness_level,
12
  fitness_goal: user.preferences.fitness_goal,
13
  }).lean();
 
14
  let index = Math.floor(Math.random() * workouts.length);
15
  const userRegisteredWorkout = new UserRegisteredWorkout({
16
  user: user._id,
 
11
  fitness_level: user.fitness_level,
12
  fitness_goal: user.preferences.fitness_goal,
13
  }).lean();
14
+ if (workouts.length === 0) return;
15
  let index = Math.floor(Math.random() * workouts.length);
16
  const userRegisteredWorkout = new UserRegisteredWorkout({
17
  user: user._id,
src/seeder/seeders/008-ingredients.seeder.ts CHANGED
@@ -8,8 +8,8 @@ export default seederWrapper(Ingredient, async () => {
8
  name: ingredientName,
9
  serving_size: faker.number.int({ min: 5, max: 20 }),
10
  servings_count: faker.number.int({ min: 1, max: 5 }),
11
- serving_size_unit: "unknown",
12
- servings_count_unit: "unknown",
13
  calories: faker.number.int({ min: 10, max: 20 }),
14
  carbs: faker.number.int({ min: 10, max: 20 }),
15
  proteins: faker.number.int({ min: 10, max: 20 }),
 
8
  name: ingredientName,
9
  serving_size: faker.number.int({ min: 5, max: 20 }),
10
  servings_count: faker.number.int({ min: 1, max: 5 }),
11
+ serving_size_unit: "Grams",
12
+ servings_count_unit: "servings",
13
  calories: faker.number.int({ min: 10, max: 20 }),
14
  carbs: faker.number.int({ min: 10, max: 20 }),
15
  proteins: faker.number.int({ min: 10, max: 20 }),
src/seeder/seeders/010-mealPlan.seeder.ts CHANGED
@@ -32,7 +32,7 @@ export default seederWrapper(MealPlan, async () => {
32
  }
33
 
34
  let o = {
35
- image: `https://placehold.co/300x400`,
36
  description: 'This is a description of the meal plan.',
37
  duration: 7,
38
  level: [FitnessLevel.BEGINNER, FitnessLevel.INTERMEDIATE, FitnessLevel.ADVANCED][i % 3],
 
32
  }
33
 
34
  let o = {
35
+ image: `https://t4.ftcdn.net/jpg/01/81/12/37/360_F_181123726_invADRiRZle7YWLYfkEHz0mUfWH60kVZ.jpg`,
36
  description: 'This is a description of the meal plan.',
37
  duration: 7,
38
  level: [FitnessLevel.BEGINNER, FitnessLevel.INTERMEDIATE, FitnessLevel.ADVANCED][i % 3],