• Mahmoud Aglan's avatar
    fix(training): give generated sessions a branch, and reserve the pitch they... · 5c5d1330
    Mahmoud Aglan authored
    fix(training): give generated sessions a branch, and reserve the pitch they were actually scheduled on
    
    Three defects on one path, all silent, all found while auditing a tenant whose
    sessions were invisible on every branch screen.
    
    BranchContext::branchIdForStamping() returns null in console and queue context —
    deliberately, because a cron that silently billed one branch would be worse than
    an unfiltered read. But that is exactly where sessions are born: the 02:00
    sessions:generate-upcoming run, and the TrainingSchedule::saved() hook. So
    SessionGeneratorService and AttendanceGenerationService, which both relied on the
    BelongsToBranch creating hook, have been writing branch_id NULL since they were
    written. On a strictly-scoped table that is not a leak but a disappearance: the
    row is in the database, counted by SQL, and on no screen in the product. It is
    also why attendance:backfill exists at 02:30 — it repairs the attendance half
    nightly, with the same session -> group attribution now applied at the source.
    
    CreateAutoReservation resolved the schedule by (training_group_id, day_of_week)
    and took ->first(): no start_time match, no is_active filter, no ordering. A
    group that trains twice on one weekday, or that has a deactivated row sitting
    beside a live one, booked whichever row sorted first — the wrong hour, or another
    branch's pitch entirely. The session already records which schedule row produced
    it, so use it; the (group, weekday) lookup survives only as a fallback for a
    session with no schedule_id, and now matches on time and is_active.
    
    The listener swallows its own exceptions into a log line, so none of this ever
    surfaced as an error.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    5c5d1330
Name
Last commit
Last update
Screenshots Loading commit data...
app Loading commit data...
bootstrap Loading commit data...
config Loading commit data...
database Loading commit data...
docker Loading commit data...
docs Loading commit data...
docs-site Loading commit data...
flutter_shell Loading commit data...
gap-filling-plans Loading commit data...
lang Loading commit data...
marketing-site Loading commit data...
plans Loading commit data...
public Loading commit data...
reference/oc-sport Loading commit data...
resources Loading commit data...
routes Loading commit data...
scripts Loading commit data...
storage Loading commit data...
tests Loading commit data...
.dockerignore Loading commit data...
.editorconfig Loading commit data...
.env.example Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.npmrc Loading commit data...
Beanding Guide.txt Loading commit data...
CLAUDE.md Loading commit data...
Dockerfile Loading commit data...
README.md Loading commit data...
artisan Loading commit data...
captain-definition Loading commit data...
composer.json Loading commit data...
composer.lock Loading commit data...
deploy.sh Loading commit data...
elcaptain-sportsonly-db.md Loading commit data...
one-click-app.yml Loading commit data...
package-lock.json Loading commit data...
package.json Loading commit data...
phpunit.xml Loading commit data...
system info.txt Loading commit data...
vite.config.js Loading commit data...
نادى الشيخ زايد كشف بيانات اللاعبين (2).html Loading commit data...