From 93c568039758990979cb6ff1e96f6a7fbba0ddbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gierwia=C5=82o?= Date: Sun, 23 Nov 2025 23:05:23 +0100 Subject: [PATCH] docs: update documentation with recent features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Recording Matching System section (auto-matching algorithm) - Add Competitor Number (Bib) Support section - Add Frontend Refactoring section (component extraction, constants) - Update test count: 223 → 286 tests (73% coverage) - Update dates to 2025-11-23 --- docs/TODO.md | 46 +++++++++---- docs/archive/COMPLETED.md | 132 +++++++++++++++++++++++++++++++++++++- 2 files changed, 165 insertions(+), 13 deletions(-) diff --git a/docs/TODO.md b/docs/TODO.md index b92cc20..588d773 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -14,15 +14,16 @@ **Progress:** 100% MVP complete **Status:** Ready for production deployment -### 🔧 CURRENT STATUS - Backend Tests (2025-11-20) - ✅ ALL PASSING! +### 🔧 CURRENT STATUS - Backend Tests (2025-11-23) - ✅ ALL PASSING! -**Test Status:** 223/223 passing (100%) - ✅ ALL TESTS FIXED! -- **Initial state:** 145/223 (65%) +**Test Status:** 286/286 passing (100%) - ✅ ALL TESTS FIXED! +- **Initial state:** 145/223 (65%) - 2025-11-20 - **After cleanup fixes:** 189/223 (84.8%) -- **Final state:** 223/223 (100%) -- **Total improvement:** +78 tests (+35%) +- **After test isolation:** 223/223 (100%) +- **After new features:** 286/286 (100%) - 2025-11-23 +- **Total improvement:** +141 tests (+63 new tests) -**Code Coverage:** 71.31% (up from ~45%) +**Code Coverage:** 73.32% (up from ~45%) **✅ All fixes completed:** 1. **Test cleanup** - replaced `deleteMany({})` with selective deletion: @@ -300,7 +301,7 @@ 9. ✅ **Account Lockout:** Implemented after failed attempts 10. ✅ **Defense in Depth:** Multiple security layers 11. ✅ **WebRTC P2P:** Videos don't touch server (privacy + security) -12. ✅ **Test Coverage:** 223/223 tests passing (71% coverage) +12. ✅ **Test Coverage:** 286/286 tests passing (73% coverage) --- @@ -429,6 +430,27 @@ See the complete security audit report generated by nodejs-security-auditor agen - Match requests (incoming/outgoing) management - Toast notifications, loading skeletons - Socket stability improvements (heartbeat, auto-reconnect) +- **Competitor Number (Bib) Support (2025-11-22)** + - New `competitorNumber` field in EventParticipant model + - Migration: `20251121210620_add_competitor_number` + - Display competitor numbers in event UI + - Used by auto-matching system to identify dancers +- **Recording Matching System (2025-11-22)** + - Auto-matching algorithm for recording partners (`backend/src/services/matching.js`) + - RecordingSuggestion model for storing match suggestions + - Schedule config for division collision groups (divisions in same slot collide) + - Heat buffer calculation (1 heat after dancing before can record) + - Location-based preference scoring (same city > same country > anyone) + - Max recordings per person limit (3) + - Frontend RecordingTab component with suggestions UI + - API endpoints for running matching and managing suggestions +- **Frontend Refactoring (2025-11-23)** + - Extracted DashboardPage into components (DashboardHeader, EventCard, MatchCard, MatchRequestCard) + - Extracted EventDetailsPage into components + - Extracted ProfilePage into ProfileForm and PasswordChangeForm + - Extracted MatchCard component from MatchesPage + - Added status constants (MATCH_STATUS, SUGGESTION_STATUS, CONNECTION_STATE, SUGGESTION_TYPE) + - Backend constants module (`backend/src/constants/`) **See:** `docs/archive/COMPLETED.md` for full list of completed tasks @@ -767,8 +789,8 @@ See the complete security audit report generated by nodejs-security-auditor agen - [x] ✅ Testing: - Integration tests (API endpoints) ✅ - WebRTC connection tests ✅ - - 223/223 tests passing (100%) ✅ - - 71% code coverage ✅ + - 286/286 tests passing (100%) ✅ + - 73% code coverage ✅ - [x] ✅ PWA features: - Web app manifest ✅ - Service worker (offline support) ✅ @@ -822,7 +844,7 @@ See the complete security audit report generated by nodejs-security-auditor agen - [ ] ⏳ HTTPS setup (Let's Encrypt) - Requires server ### Testing -- [x] ✅ Backend tests (Jest + Supertest) - 223/223 passing, 71% coverage +- [x] ✅ Backend tests (Jest + Supertest) - 286/286 passing, 73% coverage - [x] ✅ WebRTC tests - 7 backend tests passing - [x] ✅ Socket.IO tests - Complete coverage - [x] ✅ Security tests (CSRF, rate limiting, auth) @@ -877,7 +899,7 @@ git commit -m "feat: description" ## 📝 Notes - ✅ All MVP features implemented and tested -- ✅ 223/223 backend tests passing (71% coverage) +- ✅ 286/286 backend tests passing (73% coverage) - ✅ Production deployment ready (Docker configs, scripts, monitoring) - ✅ Security hardened (CSRF, rate limiting, account lockout) - ✅ PWA enabled (offline support, iOS compatible) @@ -892,4 +914,4 @@ git commit -m "feat: description" --- -**Last Updated:** 2025-11-21 +**Last Updated:** 2025-11-23 diff --git a/docs/archive/COMPLETED.md b/docs/archive/COMPLETED.md index 1ca40e5..ff81fd1 100644 --- a/docs/archive/COMPLETED.md +++ b/docs/archive/COMPLETED.md @@ -809,7 +809,137 @@ Centralized dashboard for logged-in users to: --- -**Last Updated:** 2025-11-21 (Dashboard implementation completed) +## ✅ Competitor Number (Bib) Support (COMPLETED 2025-11-22) + +**Status:** Completed +**Commits:** 1 commit + +### Overview +Added competitor number (bib number) support for event participants, used by the auto-matching system to identify who is dancing (competitor) vs who can record. + +### Implementation +- [x] ✅ **Database migration** `20251121210620_add_competitor_number` + - Added `competitorNumber` field to EventParticipant model + - Optional string field for bib/competitor number +- [x] ✅ **API updates** + - EventParticipant includes competitorNumber in responses + - Used by matching algorithm to identify dancers +- [x] ✅ **Frontend display** + - Competitor numbers shown in event UI + +### Git Commits +1. `feat(events): add competitor number (bib) support` + +--- + +## ✅ Recording Matching System (COMPLETED 2025-11-22) + +**Status:** Completed +**Time Spent:** ~4 hours +**Commits:** 3 commits + +### Overview +Auto-matching system that pairs dancers with recorders for video capture during competitions. The algorithm considers: +- Heat collision avoidance (can't record while dancing) +- Schedule config for division slot collision groups +- Buffer time (1 heat after dancing before can record) +- Location preference (same city > same country > anyone) +- Max recordings per person limit (3) + +### Backend Implementation +- [x] ✅ **Matching service** `backend/src/services/matching.js` + - `runMatching(eventId)` - Main algorithm + - `buildDivisionSlotMap()` - Parse schedule config + - `getTimeSlot()` - Calculate slot identifier + - `getBufferSlots()` - Buffer after dancing + - `hasCollision()` - Check availability + - `getCoverableHeats()` - Find recordable heats + - `getLocationScore()` - Preference scoring + - `saveMatchingResults()` - Persist suggestions + - `getUserSuggestions()` - Get user's assignments +- [x] ✅ **RecordingSuggestion model** + - Links heat to suggested recorder + - Status: pending, accepted, rejected, not_found +- [x] ✅ **Schedule config** in Event model + - JSON field for slot configuration + - Divisions in same slot collide with each other +- [x] ✅ **API endpoints** in events.js + - `POST /api/events/:slug/matching/run` - Run matching algorithm + - `GET /api/events/:slug/matching/suggestions` - Get user suggestions + +### Frontend Implementation +- [x] ✅ **RecordingTab component** + - "To Be Recorded" section (heats where user needs recorder) + - "To Record" section (heats where user records someone) + - Suggestion status indicators + - Accept/decline actions + +### Constants +- [x] ✅ **SUGGESTION_STATUS** - pending, accepted, rejected, not_found +- [x] ✅ **SUGGESTION_TYPE** - toBeRecorded, toRecord + +### Git Commits +1. `feat(matching): add auto-matching system for recording partners` +2. `feat(frontend): add recording matching UI` +3. `feat(matching): add schedule config for division collision groups` + +--- + +## ✅ Frontend Refactoring (COMPLETED 2025-11-23) + +**Status:** Completed +**Commits:** 6 commits + +### Overview +Major refactoring of frontend code to extract reusable components and add status constants for better code quality. + +### Component Extraction +- [x] ✅ **DashboardPage** extracted into: + - `DashboardHeader.jsx` + - `EventCard.jsx` + - `MatchCard.jsx` + - `MatchRequestCard.jsx` + - Barrel export: `components/dashboard/index.js` +- [x] ✅ **EventDetailsPage** extracted into components +- [x] ✅ **ProfilePage** extracted into: + - `ProfileForm.jsx` (192 lines) + - `PasswordChangeForm.jsx` (99 lines) + - Reduced ProfilePage from 394 → 84 lines (-79%) +- [x] ✅ **MatchesPage** extracted: + - `MatchCard.jsx` component + - Barrel export: `components/matches/index.js` + +### Status Constants +- [x] ✅ **Frontend** `frontend/src/constants/statuses.js` + - `MATCH_STATUS` - pending, accepted, rejected, completed + - `SUGGESTION_STATUS` - pending, accepted, rejected, not_found + - `MATCH_FILTER` - all, pending, accepted + - `CONNECTION_STATE` - disconnected, connecting, connected, failed + - `SUGGESTION_TYPE` - toBeRecorded, toRecord +- [x] ✅ **Backend** `backend/src/constants/statuses.js` + - `MATCH_STATUS` - Same values as frontend + - `SUGGESTION_STATUS` - Same values as frontend +- [x] ✅ Updated all files to use constants instead of string literals + +### Test Fixes +- [x] ✅ **users.test.js** - Added wsdcId cleanup for unique constraint +- [x] ✅ **auth-phase1.5.test.js** - Added wsdcId cleanup with related data deletion +- [x] ✅ All 286 backend tests passing + +### Git Commits +1. `refactor(frontend): extract EventDetailsPage into components` +2. `refactor(frontend): extract DashboardPage into components` +3. `refactor(frontend): extract MatchCard component from MatchesPage` +4. `refactor(frontend): extract ProfileForm and PasswordChangeForm from ProfilePage` +5. `refactor(frontend): replace status string literals with constants` +6. `refactor(frontend): add CONNECTION_STATE and SUGGESTION_TYPE constants` +7. `refactor(backend): add status constants and update code to use them` +8. `fix(tests): add wsdcId cleanup to prevent unique constraint violations` + +--- + +**Last Updated:** 2025-11-23 (Recording Matching + Frontend Refactoring completed) **Note:** This file is an archive of completed phases. For current status, see SESSION_CONTEXT.md or TODO.md **MVP Status:** ✅ 100% Complete - All core features implemented, tested, and production-ready +**Test Status:** 286/286 backend tests passing (73% coverage)