shinkan-jinkendo/scripts/load/explain-readpaths.sql
Lars b06d026dd0
All checks were successful
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 57s
chore(version): update version and changelog for release 0.8.118
- Bumped APP_VERSION to 0.8.118 and updated DB_SCHEMA_VERSION to 20260514062.
- Enhanced the dashboard API with a new endpoint that consolidates training home data, allowing for a single request to retrieve upcoming training sessions, planned sessions with notes, and review pending items.
- Updated the frontend Dashboard component to utilize the new API structure, improving data loading efficiency and user experience.
- Added migration details and changelog entries to reflect the latest changes and improvements.
2026-05-14 08:53:09 +02:00

57 lines
1.9 KiB
SQL

-- Phase 2: Vorlagen für EXPLAIN (ANALYZE, BUFFERS) auf Ziel-DB mit realistischem Datenbestand.
-- Ersetzen: :token (Session), ggf. :club_id / :group_id nach Tenant; in psql: \set token '...'
-- Hinweis: Routen sind auth-geschützt — sinnvoll mit Rolle ausführen, die der API entspricht,
-- oder SQL aus Postgres-Logs normalisieren.
-- GET /api/exercises — typische Liste (Filter anpassen)
EXPLAIN (ANALYZE, BUFFERS)
SELECT e.id, e.title
FROM exercises e
WHERE e.status <> 'archived'
AND e.visibility IN ('private', 'club', 'official')
ORDER BY e.updated_at DESC, e.id DESC
LIMIT 50;
-- GET /api/exercises — mit Stufenfilter (nutzt idx_exercise_skills_exercise_level_rank)
EXPLAIN (ANALYZE, BUFFERS)
SELECT e.id, e.title
FROM exercises e
WHERE e.status <> 'archived'
AND EXISTS (
SELECT 1 FROM exercise_skills es
WHERE es.exercise_id = e.id
AND (
CASE COALESCE(
NULLIF(TRIM(LOWER(es.target_level::text)), ''),
NULLIF(TRIM(LOWER(es.required_level::text)), '')
)
WHEN 'basis' THEN 1
WHEN 'grundlagen' THEN 2
WHEN 'aufbau' THEN 3
WHEN 'fortgeschritten' THEN 4
WHEN 'optimierung' THEN 5
WHEN 'einsteiger' THEN 1
WHEN 'experte' THEN 5
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
WHEN '5' THEN 5
ELSE NULL END
) BETWEEN 2 AND 4
)
ORDER BY e.updated_at DESC, e.id DESC
LIMIT 50;
-- GET /api/training-units — Kalenderliste (ohne Blueprint)
EXPLAIN (ANALYZE, BUFFERS)
SELECT tu.id, tu.planned_date, tu.planned_time_start
FROM training_units tu
LEFT JOIN training_groups tg ON tu.group_id = tg.id
WHERE tu.framework_slot_id IS NULL
ORDER BY tu.planned_date ASC,
(tu.planned_time_start IS NULL) ASC,
tu.planned_time_start ASC NULLS LAST,
tu.id ASC
LIMIT 40;