User weight updates after session
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ node_modules
|
|||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
server\prisma\dev.db
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
|||||||
Binary file not shown.
@@ -101,8 +101,28 @@ router.post('/', async (req: any, res) => {
|
|||||||
},
|
},
|
||||||
include: { sets: true }
|
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);
|
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) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
res.status(500).json({ error: 'Server error' });
|
res.status(500).json({ error: 'Server error' });
|
||||||
|
|||||||
Reference in New Issue
Block a user