Cwiczenia: usuniecie martwego pola trudnosc z katalogu (trudnosc pozostaje tylko jako ocena cwiczacego per seria 1-5; migracja DROP kolumny Exercise.difficulty)

This commit is contained in:
tisachi
2026-10-17 08:51:12 +02:00
parent 03e0ace10a
commit 4001aab977
16 changed files with 15 additions and 455 deletions

View File

@@ -141,7 +141,6 @@ export interface Exercise {
description: string | null;
howTo: string | null;
commonMistakes: string | null;
difficulty: number;
source: string;
/** Liczba odwołań w planach treningowych. */
planExercisesCount: number;

View File

@@ -119,7 +119,6 @@ interface FormState {
name: string;
primaryMuscle: string;
secondaryMuscles: string[];
difficulty: string;
description: string;
howTo: string;
commonMistakes: string;
@@ -132,7 +131,6 @@ const EMPTY: FormState = {
name: '',
primaryMuscle: '',
secondaryMuscles: [],
difficulty: '3',
description: '',
howTo: '',
commonMistakes: '',
@@ -218,7 +216,6 @@ export default function Exercises() {
description: form.description || null,
howTo: form.howTo || null,
commonMistakes: form.commonMistakes || null,
difficulty: form.difficulty ? parseInt(form.difficulty, 10) : undefined,
equipmentIds: form.equipmentIds,
...flags,
};
@@ -282,7 +279,6 @@ export default function Exercises() {
name: ex.name,
primaryMuscle: ex.primaryMuscle,
secondaryMuscles: ex.secondaryMuscles,
difficulty: String(ex.difficulty),
description: ex.description ?? '',
howTo: ex.howTo ?? '',
commonMistakes: ex.commonMistakes ?? '',
@@ -347,7 +343,6 @@ export default function Exercises() {
{CARD_FLAG_CHIPS[k]}
</Badge>
))}
<Badge color="gray">trudność {ex.difficulty}</Badge>
{ex.planExercisesCount > 0 && (
<Badge color="yellow">
{ex.planExercisesCount === 1 ? '1 plan' : `${ex.planExercisesCount} planów`}
@@ -418,31 +413,19 @@ export default function Exercises() {
placeholder="np. Wyciskanie sztangi leżąc"
/>
</Field>
<div className="grid grid-cols-2 gap-3">
<Field label="Główny mięsień">
<Select
value={form.primaryMuscle}
onChange={(e) => setForm((f) => ({ ...f, primaryMuscle: e.target.value }))}
>
<option value="">— wybierz —</option>
{primaryOptions.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
</Select>
</Field>
<Field label="Trudność (1–10)">
<Input
type="number"
min="1"
max="10"
value={form.difficulty}
onChange={(e) => setForm((f) => ({ ...f, difficulty: e.target.value }))}
placeholder="np. 3"
/>
</Field>
</div>
<Field label="Główny mięsień">
<Select
value={form.primaryMuscle}
onChange={(e) => setForm((f) => ({ ...f, primaryMuscle: e.target.value }))}
>
<option value="">— wybierz —</option>
{primaryOptions.map((o) => (
<option key={o.value} value={o.value}>
{o.label}
</option>
))}
</Select>
</Field>
<Field label="Mięśnie pomocnicze">
{secondaryOptions.length === 0 ? (
<p className="text-dim text-[0.875rem]">

View File

@@ -45,7 +45,6 @@ const EXERCISE = {
description: 'Podstawowe ćwiczenie na klatkę.',
howTo: null,
commonMistakes: null,
difficulty: 4,
source: 'BUILTIN',
planExercisesCount: 0,
};
@@ -143,7 +142,6 @@ describe('admin Exercises page', () => {
expect(screen.getByText('triceps')).toBeInTheDocument();
expect(screen.getByText('wbudowane')).toBeInTheDocument();
expect(screen.getByText('Sztanga')).toBeInTheDocument();
expect(screen.getByText('trudność 4')).toBeInTheDocument();
});
it('pokazuje licznik planów na karcie ćwiczenia', async () => {
@@ -173,7 +171,6 @@ describe('admin Exercises page', () => {
name: 'Wyciskanie sztangi leżąc',
primaryMuscle: 'chest',
secondaryMuscles: ['triceps'],
difficulty: 4,
equipmentIds: ['eq-1', 'eq-2'],
});
});

View File

@@ -192,7 +192,6 @@ export const TEST_EXERCISES = [
description: 'Podstawowe ćwiczenie na klatkę.',
howTo: null,
commonMistakes: null,
difficulty: 4,
source: 'BUILTIN',
planExercisesCount: 1,
},

View File

@@ -0,0 +1,2 @@
-- Usuniecie katalogowego pola difficulty cwiczenia (trudnosc jest ustawiana indywidualnie per seria)
ALTER TABLE "Exercise" DROP COLUMN "difficulty";

View File

@@ -563,7 +563,6 @@ model Exercise {
description String?
howTo String?
commonMistakes String?
difficulty Int @default(3)
source ExerciseSource @default(BUILTIN)
gymId String?
trainerId String?

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,6 @@ const exerciseSchema = z.object({
description: z.string().max(2000).nullable().optional(),
howTo: z.string().max(2000).nullable().optional(),
commonMistakes: z.string().max(2000).nullable().optional(),
difficulty: z.number().int().min(1).max(10).optional(),
equipmentIds: z.array(z.string().min(1)).max(50).optional(),
...hasFlagsSchema,
});
@@ -46,7 +45,6 @@ const exerciseUpdateSchema = z.object({
description: z.string().max(2000).nullable().optional(),
howTo: z.string().max(2000).nullable().optional(),
commonMistakes: z.string().max(2000).nullable().optional(),
difficulty: z.number().int().min(1).max(10).optional(),
equipmentIds: z.array(z.string().min(1)).max(50).optional(),
...hasFlagsSchema,
});

View File

@@ -142,7 +142,6 @@ async function seedExercises() {
description: ex.description,
howTo: ex.howTo,
commonMistakes: ex.commonMistakes,
difficulty: ex.difficulty,
source: 'BUILTIN',
seedVersion: SEED_VERSION,
},
@@ -164,7 +163,6 @@ async function seedExercises() {
description: ex.description,
howTo: ex.howTo,
commonMistakes: ex.commonMistakes,
difficulty: ex.difficulty,
source: 'BUILTIN',
seedVersion: SEED_VERSION,
},

View File

@@ -9,7 +9,6 @@ export interface ExerciseInput {
description?: string | null;
howTo?: string | null;
commonMistakes?: string | null;
difficulty?: number;
/** Equipment ids to link (replaces the current set when provided). */
equipmentIds?: string[];
hasReps?: boolean;
@@ -86,7 +85,6 @@ export async function createExercise(prisma: PrismaClient, data: ExerciseInput)
description: data.description ?? null,
howTo: data.howTo ?? null,
commonMistakes: data.commonMistakes ?? null,
difficulty: data.difficulty ?? 3,
source: 'BUILTIN',
// undefined → Prisma default (has* pozostają przy domyślnych kombinacjach)
hasReps: data.hasReps,
@@ -125,7 +123,6 @@ export async function updateExercise(
description: data.description,
howTo: data.howTo,
commonMistakes: data.commonMistakes,
difficulty: data.difficulty,
hasReps: data.hasReps,
hasLoad: data.hasLoad,
hasRest: data.hasRest,

View File

@@ -622,7 +622,6 @@ export const openapi: Record<string, unknown> = {
description: { type: 'string', nullable: true },
howTo: { type: 'string', nullable: true },
commonMistakes: { type: 'string', nullable: true },
difficulty: { type: 'integer', minimum: 1, maximum: 10 },
equipmentIds: { type: 'array', items: { type: 'string' } },
hasReps: { type: 'boolean' },
hasLoad: { type: 'boolean' },

View File

@@ -66,7 +66,6 @@ export async function createExercise(overrides: { slug?: string; name?: string }
description: 'Test exercise',
howTo: 'Test how-to',
commonMistakes: 'Test mistakes',
difficulty: 3,
source: 'BUILTIN',
},
});

View File

@@ -646,7 +646,6 @@ describe('admin routes', () => {
hasCardio: true,
hasTime: true,
description: 'Bieganie.',
difficulty: 4,
});
expect(res.status).toBe(201);
expect(res.body.exercise).toMatchObject({
@@ -657,7 +656,6 @@ describe('admin routes', () => {
hasTime: true,
hasSpeed: false,
description: 'Bieganie.',
difficulty: 4,
planExercisesCount: 0,
});

View File

@@ -26,7 +26,6 @@ describe('exercises routes', () => {
secondaryMuscles: ['triceps'],
equipment: [],
source: 'BUILTIN',
difficulty: 3,
});
});

View File

@@ -253,7 +253,6 @@ export interface Exercise {
description: string | null;
howTo: string | null;
commonMistakes: string | null;
difficulty: number;
source: string;
}

View File

@@ -92,7 +92,6 @@ function makeExercise(id: string, name: string, primaryMuscle: string) {
description: null,
howTo: null,
commonMistakes: null,
difficulty: 3,
source: 'BUILTIN',
};
}