Skip to content

Commit

Permalink
modify update
Browse files Browse the repository at this point in the history
  • Loading branch information
alyuza committed Dec 23, 2023
1 parent ae6fab3 commit 0657e81
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Backend/service/workoutService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ const createSwimming = async (req, res) => {

const updateWorkout = async (req, res) => {
const id = req.params.id;
// const { title, description, distance, time, calorie } = req.body;
// const usernameInput = req.username;
const { title, description, distance, time, date } = req.body;
try {
const { title, description, distance, time, date } = req.body;
const workout = await req.db
.collection("workouts")
.findOne({ _id: new ObjectId(id) });
Expand All @@ -137,7 +135,7 @@ const updateWorkout = async (req, res) => {
} else if (activityType === "swimming") {
calorieCostPerKm = 80;
}
const calories = (calorieCostPerKm * distance * time) / 60;
const calorie = (calorieCostPerKm * distance * time) / 60;
await req.db.collection("workouts").findOneAndUpdate(
{ _id: new ObjectId(id) },
{
Expand All @@ -147,7 +145,7 @@ const updateWorkout = async (req, res) => {
distance,
time,
date,
calories,
calorie,
},
}
);
Expand Down

0 comments on commit 0657e81

Please sign in to comment.