User weight updates after session
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
server\prisma\dev.db
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
|
||||
Binary file not shown.
@@ -101,8 +101,28 @@ router.post('/', async (req: any, res) => {
|
||||
},
|
||||
include: { sets: true }
|
||||
});
|
||||
|
||||
// Update user profile weight if session has weight and is finished
|
||||
if (weight && end) {
|
||||
await prisma.userProfile.upsert({
|
||||
where: { userId },
|
||||
create: { userId, weight },
|
||||
update: { weight }
|
||||
});
|
||||
}
|
||||
|
||||
return res.json(created);
|
||||
}
|
||||
|
||||
// Update user profile weight if session has weight and is finished (for update case too)
|
||||
if (weight && end) {
|
||||
await prisma.userProfile.upsert({
|
||||
where: { userId },
|
||||
create: { userId, weight },
|
||||
update: { weight }
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
res.status(500).json({ error: 'Server error' });
|
||||
|
||||
Reference in New Issue
Block a user