Trening: dodanie cwiczenia tworzy automatycznie pierwsza serie; limit niezapisanego bonusu liczony na cwiczenie (wczesniej na sesje)
This commit is contained in:
@@ -139,8 +139,8 @@ export function createSessionRoutes({ prisma }: AppDeps) {
|
||||
* /sessions/exercises/{id}/sets:
|
||||
* post:
|
||||
* summary: Add an extra (bonus) set. Only when all planned sets of this exercise are
|
||||
* recorded (added exercises have no norm) and no extra set is still pending
|
||||
* (at most one pending extra per session).
|
||||
* recorded (added exercises have no norm) and this exercise has no extra set
|
||||
* still pending (at most one pending extra per exercise).
|
||||
* tags: [Sessions]
|
||||
* responses:
|
||||
* 201: { description: Created }
|
||||
|
||||
@@ -241,8 +241,8 @@ export async function updateExercise(
|
||||
/**
|
||||
* Add an extra (bonus) set to a session exercise.
|
||||
* Allowed once every planned (norm) set of THIS exercise is recorded (exercises
|
||||
* added to the session have no norm — vacuously satisfied), and no extra set is
|
||||
* still pending — at most one pending extra set per session.
|
||||
* added to the session have no norm — vacuously satisfied), and this exercise has
|
||||
* no extra set still pending — at most one pending extra set per exercise.
|
||||
* Norm of other exercises must not block exceeding one that is already done:
|
||||
* "nie dowożę / dowożę / przekraczam" is an option per exercise, in order.
|
||||
*/
|
||||
@@ -259,13 +259,7 @@ export async function addSet(prisma: PrismaClient, exerciseId: string, userId: s
|
||||
'All planned sets of this exercise must be recorded before adding an extra set',
|
||||
);
|
||||
const pendingExtra = await tx.sessionSet.count({
|
||||
where: {
|
||||
// usunięte ćwiczenia nie liczą się do limitu — ich seria „w toku" jest nietykalna
|
||||
exercise: { sessionId: exercise.sessionId, removed: false },
|
||||
planSetId: null,
|
||||
reps: null,
|
||||
removed: false,
|
||||
},
|
||||
where: { exerciseId: exercise.id, planSetId: null, reps: null, removed: false },
|
||||
});
|
||||
if (pendingExtra > 0) throw badRequest('An extra set is already in progress');
|
||||
const maxIndex = await tx.sessionSet.aggregate({
|
||||
|
||||
@@ -831,7 +831,7 @@ export const openapi: Record<string, unknown> = {
|
||||
post: {
|
||||
tags: ['Sessions'],
|
||||
summary:
|
||||
"Add extra (bonus) set to session exercise (requires this exercise's planned sets recorded; at most one pending extra per session)",
|
||||
"Add extra (bonus) set to session exercise (requires this exercise's planned sets recorded; at most one pending extra per exercise)",
|
||||
security: [{ bearerAuth: [] }],
|
||||
parameters: [{ name: 'id', in: 'path', required: true, schema: { type: 'string' } }],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user