diff --git a/AI-coach-agent/docs/SWING_REPORT_API.md b/AI-coach-agent/docs/SWING_REPORT_API.md index 1f93fffbae7a0858b60ae3da67ee0334d7ac673c..f4155ef3caf4cc11c91a8d6b715826eb74bd8d20 100644 --- a/AI-coach-agent/docs/SWING_REPORT_API.md +++ b/AI-coach-agent/docs/SWING_REPORT_API.md @@ -1,6 +1,6 @@ # Swing report API: expected output -**Status:** proposed, version `1.0`. +**Status:** historical proposal for version `1.0`. This document's sample scores and limited-value aggregation are superseded by the [implemented 1.1 contract and scoring behavior](../../docs/motion-coach-v1.1.md). The receiver accepts both input versions; the report retains version `1.0` with additive interval fields. **Input:** one swing analysis payload, following the ML engineer's contract v1.0. diff --git a/AI-coach-agent/src/ai_coach/knowledge/benchmarks.yaml b/AI-coach-agent/src/ai_coach/knowledge/benchmarks.yaml index e857cdcce14a986b28ae553e748469b6b62e77b8..fccd33cd4908f2790017f6d74627533add6d775e 100644 --- a/AI-coach-agent/src/ai_coach/knowledge/benchmarks.yaml +++ b/AI-coach-agent/src/ai_coach/knowledge/benchmarks.yaml @@ -1,6 +1,6 @@ -# GENERATED by tools/build_benchmarks.py from data_ref/calibration/contract_v1/contract_v1_benchmarks.json. +# GENERATED by tools/build_benchmarks.py from data_ref/calibration/contract_v1 and contract_v1_1. # Do not edit by hand: change the generator or the source data and regenerate. -version: 2026-10-21.1 +version: 2026-10-31.1 kind: reference_interval source_reference: OpenBiomechanics Project hitting dataset (Driveline), percentiles P25-P75 and P10-P90 sign_convention: 'raw contract values: wrap180(shoulder_heading - hip_heading), not mirrored by batting hand' @@ -167,3 +167,309 @@ metrics: lower: 15.6 upper: 47.7 median: 30.2 + torso_inclination_at_stride_start: + unit: deg + cells: + right/high_school: + benchmark_id: obp-contract-v1.torso_inclination_at_stride_start.right.high_school + population: High school right-handed hitters (12 athletes) + n_athletes: 12 + n_swings: 54 + on_target: + lower: 16.477 + upper: 22.165 + satisfactory: + lower: 13.647 + upper: 26.95 + median: 18.132 + right/college: + benchmark_id: obp-contract-v1.torso_inclination_at_stride_start.right.college + population: College right-handed hitters (50 athletes) + n_athletes: 50 + n_swings: 312 + on_target: + lower: 12.451 + upper: 21.514 + satisfactory: + lower: 10.482 + upper: 23.561 + median: 17.587 + right/pro: + benchmark_id: obp-contract-v1.torso_inclination_at_stride_start.right.pro + population: Professional right-handed hitters (8 athletes) + n_athletes: 8 + n_swings: 46 + on_target: + lower: 12.79 + upper: 19.706 + satisfactory: + lower: 10.569 + upper: 20.202 + median: 16.559 + left/college: + benchmark_id: obp-contract-v1.torso_inclination_at_stride_start.left.college + population: College left-handed hitters (23 athletes) + n_athletes: 23 + n_swings: 148 + on_target: + lower: 10.876 + upper: 20.913 + satisfactory: + lower: 7.027 + upper: 21.64 + median: 15.483 + hip_shoulder_separation_at_stride_start: + unit: deg + cells: + right/high_school: + benchmark_id: obp-contract-v1.hip_shoulder_separation_at_stride_start.right.high_school + population: High school right-handed hitters (12 athletes) + n_athletes: 12 + n_swings: 54 + on_target: + lower: -15.439 + upper: -5.326 + satisfactory: + lower: -19.805 + upper: -2.582 + median: -8.689 + right/college: + benchmark_id: obp-contract-v1.hip_shoulder_separation_at_stride_start.right.college + population: College right-handed hitters (50 athletes) + n_athletes: 50 + n_swings: 312 + on_target: + lower: -13.629 + upper: -6.051 + satisfactory: + lower: -15.908 + upper: 0.649 + median: -8.338 + right/pro: + benchmark_id: obp-contract-v1.hip_shoulder_separation_at_stride_start.right.pro + population: Professional right-handed hitters (8 athletes) + n_athletes: 8 + n_swings: 46 + on_target: + lower: -7.626 + upper: -3.168 + satisfactory: + lower: -10.813 + upper: 0.28 + median: -5.479 + left/college: + benchmark_id: obp-contract-v1.hip_shoulder_separation_at_stride_start.left.college + population: College left-handed hitters (23 athletes) + n_athletes: 23 + n_swings: 148 + on_target: + lower: -1.404 + upper: 7.816 + satisfactory: + lower: -4.207 + upper: 9.349 + median: 3.77 + pelvis_rotation_to_contact: + unit: deg + cells: + right/high_school: + benchmark_id: obp-contract-v1.pelvis_rotation_to_contact.right.high_school + population: High school right-handed hitters (12 athletes) + n_athletes: 12 + n_swings: 75 + on_target: + lower: 95.252 + upper: 109.403 + satisfactory: + lower: 71.621 + upper: 113.136 + median: 101.385 + right/college: + benchmark_id: obp-contract-v1.pelvis_rotation_to_contact.right.college + population: College right-handed hitters (50 athletes) + n_athletes: 50 + n_swings: 339 + on_target: + lower: 92.239 + upper: 112.851 + satisfactory: + lower: 87.519 + upper: 119.838 + median: 99.919 + right/pro: + benchmark_id: obp-contract-v1.pelvis_rotation_to_contact.right.pro + population: Professional right-handed hitters (8 athletes) + n_athletes: 8 + n_swings: 54 + on_target: + lower: 101.744 + upper: 110.155 + satisfactory: + lower: 91.703 + upper: 111.75 + median: 107.33 + left/college: + benchmark_id: obp-contract-v1.pelvis_rotation_to_contact.left.college + population: College left-handed hitters (23 athletes) + n_athletes: 23 + n_swings: 158 + on_target: + lower: 91.944 + upper: 109.794 + satisfactory: + lower: 71.154 + upper: 116.492 + median: 102.235 + lead_knee_extension_to_contact: + unit: deg + cells: + right/high_school: + benchmark_id: obp-contract-v1.lead_knee_extension_to_contact.right.high_school + population: High school right-handed hitters (12 athletes) + n_athletes: 12 + n_swings: 75 + on_target: + lower: 20.026 + upper: 33.401 + satisfactory: + lower: 13.012 + upper: 46.79 + median: 26.679 + right/college: + benchmark_id: obp-contract-v1.lead_knee_extension_to_contact.right.college + population: College right-handed hitters (50 athletes) + n_athletes: 50 + n_swings: 339 + on_target: + lower: 24.36 + upper: 37.117 + satisfactory: + lower: 11.016 + upper: 41.516 + median: 30.214 + right/pro: + benchmark_id: obp-contract-v1.lead_knee_extension_to_contact.right.pro + population: Professional right-handed hitters (8 athletes) + n_athletes: 8 + n_swings: 54 + on_target: + lower: 26.439 + upper: 39.377 + satisfactory: + lower: 25.249 + upper: 44.219 + median: 31.089 + left/college: + benchmark_id: obp-contract-v1.lead_knee_extension_to_contact.left.college + population: College left-handed hitters (23 athletes) + n_athletes: 23 + n_swings: 158 + on_target: + lower: 22.863 + upper: 35.16 + satisfactory: + lower: 18.307 + upper: 44.186 + median: 27.741 + torso_inclination_at_contact: + unit: deg + cells: + right/high_school: + benchmark_id: obp-contract-v1.torso_inclination_at_contact.right.high_school + population: High school right-handed hitters (12 athletes) + n_athletes: 12 + n_swings: 75 + on_target: + lower: 23.757 + upper: 28.781 + satisfactory: + lower: 23.44 + upper: 31.166 + median: 25.992 + right/college: + benchmark_id: obp-contract-v1.torso_inclination_at_contact.right.college + population: College right-handed hitters (50 athletes) + n_athletes: 50 + n_swings: 339 + on_target: + lower: 23.095 + upper: 29.757 + satisfactory: + lower: 19.666 + upper: 34.174 + median: 25.627 + right/pro: + benchmark_id: obp-contract-v1.torso_inclination_at_contact.right.pro + population: Professional right-handed hitters (8 athletes) + n_athletes: 8 + n_swings: 54 + on_target: + lower: 25.461 + upper: 29.828 + satisfactory: + lower: 23.969 + upper: 32.311 + median: 27.233 + left/college: + benchmark_id: obp-contract-v1.torso_inclination_at_contact.left.college + population: College left-handed hitters (23 athletes) + n_athletes: 23 + n_swings: 158 + on_target: + lower: 26.972 + upper: 30.407 + satisfactory: + lower: 23.096 + upper: 32.363 + median: 28.916 + shoulder_rotation_after_contact: + unit: deg + cells: + right/high_school: + benchmark_id: obp-contract-v1.shoulder_rotation_after_contact.right.high_school + population: High school right-handed hitters (12 athletes) + n_athletes: 12 + n_swings: 75 + on_target: + lower: 33.222 + upper: 49.491 + satisfactory: + lower: 30.717 + upper: 50.917 + median: 46.241 + right/college: + benchmark_id: obp-contract-v1.shoulder_rotation_after_contact.right.college + population: College right-handed hitters (50 athletes) + n_athletes: 50 + n_swings: 339 + on_target: + lower: 32.14 + upper: 42.911 + satisfactory: + lower: 24.678 + upper: 50.737 + median: 39.678 + right/pro: + benchmark_id: obp-contract-v1.shoulder_rotation_after_contact.right.pro + population: Professional right-handed hitters (8 athletes) + n_athletes: 8 + n_swings: 54 + on_target: + lower: 41.326 + upper: 51.044 + satisfactory: + lower: 39.631 + upper: 57.817 + median: 48.357 + left/college: + benchmark_id: obp-contract-v1.shoulder_rotation_after_contact.left.college + population: College left-handed hitters (23 athletes) + n_athletes: 23 + n_swings: 158 + on_target: + lower: 34.359 + upper: 44.89 + satisfactory: + lower: 28.626 + upper: 53.315 + median: 40.799 diff --git a/AI-coach-agent/src/ai_coach/knowledge/swing_metrics.yaml b/AI-coach-agent/src/ai_coach/knowledge/swing_metrics.yaml index 7d3bace6872094f391b2b5debdf49785bc3e7b7d..0c44c00252410c0d167731ea9da3de39220ee967 100644 --- a/AI-coach-agent/src/ai_coach/knowledge/swing_metrics.yaml +++ b/AI-coach-agent/src/ai_coach/knowledge/swing_metrics.yaml @@ -1,4 +1,4 @@ -# Swing report metric registry (contract 1.0 measurements). Agent-owned; coaching text and drill choices need coach review. +# Swing report metric registry (contracts 1.0 and 1.1). Reference comparisons are not technique diagnoses. # # Sign convention. The contract reports separation as wrap180(shoulder_heading - hip_heading) with ONE convention for # both batting sides, so the same body position has opposite signs for right- and left-handed hitters. Benchmarks are kept @@ -11,8 +11,8 @@ # Drill ids come from drills.yaml (hitting). `drill_review`: spec = the choice shown in docs/SWING_REPORT_API.md; # needs_coach_review = a sensible pick from the starter library that a coach must confirm. # Text rules: plain words, no numbers, no good/bad judgements (guardrails.BANNED). -version: "1.0" # coaching_rules_version -measurement_definitions_version: "1.0" +version: "1.1" # coaching_rules_version +measurement_definitions_version: "1.1" groups: - group: balance_load @@ -43,15 +43,15 @@ metrics: what_it_means: When your front foot lands, how differently your hips and shoulders are pointing. in_range_text: Your hips and shoulders were turned about the way most hitters are when your front foot landed. directions: - above: # shoulders already turning open (less separation) at landing - meaning: shoulders_open_early - result_text: - satisfactory: Your shoulders were starting to turn open a little early when your front foot landed. - off_target: Your shoulders were already turning open when your front foot landed. - headline: Your shoulders start turning open before your front foot lands. - coach_message: Your shoulders start turning toward the pitcher before your front foot lands. Keeping them closed a little longer lets your hips lead and stores more energy for the swing. - coach_tip: Let your hips start the turn while your shoulders stay closed. - practice_feel: Keep your front shoulder pointed at the pitcher until your front foot is down. + above: # relative orientation at landing; does not establish when opening began + meaning: shoulders_more_open_at_landing + result_text: + satisfactory: Your shoulders were more open relative to your hips than the reference when your front foot landed. + off_target: Your shoulders were more open relative to your hips than the reference when your front foot landed. + headline: Your hip and shoulder angle at foot down differs from the reference. + coach_message: Your hip and shoulder angle at foot down differs from the reference. Review this moment before changing your swing. + coach_tip: Review your hip and shoulder angle when your front foot lands. + practice_feel: Keep your turn smooth and comfortable. drill_id: hit_13 drill_review: spec below: # shoulders wound far behind the hips at landing @@ -60,14 +60,14 @@ metrics: satisfactory: Your shoulders were turned back a little more than most hitters when your front foot landed. off_target: Your shoulders were turned far back behind your hips when your front foot landed. headline: Your shoulders are wound far back when your front foot lands. - coach_message: Your shoulders are turned well behind your hips when your front foot lands. A smaller, easier coil can make it simpler to start the swing on time. - coach_tip: Load to a comfortable coil and keep your balance over your back leg. - practice_feel: Coil your shoulders just enough to feel ready, then let your hips start the turn. + coach_message: Your shoulders are turned farther behind your hips than the reference at foot down. Review this moment before changing your swing. + coach_tip: Review your hip and shoulder angle when your front foot lands. + practice_feel: Keep your turn smooth and comfortable. drill_id: hit_09 drill_review: needs_coach_review maintain: - coach_message: Your hips and shoulders were set the way most hitters are when your front foot landed. Keep that timing by letting your hips start the turn while your shoulders stay closed. - practice_feel: Land with your front shoulder still pointed at the pitcher, then let your hips start the turn. + coach_message: Your hip and shoulder angle at foot down was within the reference range. Keep your movement smooth and repeatable. + practice_feel: Keep your turn smooth and comfortable. drill_id: hit_14 drill_review: needs_coach_review @@ -88,9 +88,9 @@ metrics: satisfactory: Your step was a little longer than most hitters take. off_target: Your step was much longer than most hitters take. headline: Your front foot steps out farther than most hitters. - coach_message: Your front foot reaches out farther than most hitters. A shorter, quieter step can help you stay balanced and keep your head still. - coach_tip: Take a short, soft step and land under control. - practice_feel: Take a short, quiet step and land softly on your front foot. + coach_message: Your foot movement was longer than the reference range. Check the drill and marked moments before changing your step. + coach_tip: Review where your stride starts and where your foot lands. + practice_feel: Use a comfortable, repeatable step. drill_id: hit_01 drill_review: needs_coach_review below: @@ -99,9 +99,9 @@ metrics: satisfactory: Your step was a little shorter than most hitters take. off_target: Your step was much shorter than most hitters take. headline: Your front foot barely moves forward before you swing. - coach_message: Your front foot moves forward less than most hitters. Letting the load finish and then stepping toward the pitcher can give your swing more rhythm. - coach_tip: Finish your load, then step toward the pitcher. - practice_feel: Load back first, then let your front foot step toward the pitcher. + coach_message: Your foot movement was shorter than the reference range. Check the drill and marked moments before changing your step. + coach_tip: Review where your stride starts and where your foot lands. + practice_feel: Use a comfortable, repeatable step. drill_id: hit_04 drill_review: needs_coach_review maintain: @@ -126,9 +126,9 @@ metrics: satisfactory: Your shoulders were turned a little ahead of your hips when the bat met the ball. off_target: Your shoulders had turned well ahead of your hips when the bat met the ball. headline: Your shoulders turn ahead of your hips by the time the bat meets the ball. - coach_message: Your shoulders get ahead of your hips by the time the bat meets the ball. Letting your hips lead the turn keeps your upper body from pulling off the ball. - coach_tip: Start the turn with your back hip and let your chest follow. - practice_feel: Turn your back hip first and feel your chest follow a moment later. + coach_message: Your shoulders were ahead of your hips at the marked hit. Review this moment before changing your swing. + coach_tip: Review the marked hit and your hip and shoulder angle. + practice_feel: Keep your turn smooth and comfortable. drill_id: hit_14 drill_review: needs_coach_review below: # hips turned well ahead of the shoulders at contact @@ -137,17 +137,260 @@ metrics: satisfactory: Your hips were turned a little ahead of your shoulders when the bat met the ball. off_target: Your hips had turned well ahead of your shoulders when the bat met the ball. headline: Your hips spin well ahead of your shoulders by the time the bat meets the ball. - coach_message: Your hips keep spinning well ahead of your shoulders at contact. Firming up your front leg helps your hips stop so your upper body can catch up. - coach_tip: Press into a firm front leg as you turn. - practice_feel: Stride, then press into the ground with your front leg as you turn. + coach_message: Your hips were ahead of your shoulders at the marked hit. Review this moment before changing your swing. + coach_tip: Review the marked hit and your hip and shoulder angle. + practice_feel: Keep your turn smooth and comfortable. drill_id: hit_12 drill_review: needs_coach_review maintain: # every rated result is on target and this is the area to keep sharp - coach_message: Your hips and shoulders lined up the way most hitters do when the bat met the ball. Keep that order by letting your hips lead the turn every swing. - practice_feel: Turn your back hip first and feel your chest follow a moment later. + coach_message: Your hip and shoulder angle at the marked hit was within the reference range. Keep your movement smooth and repeatable. + practice_feel: Keep your turn smooth and comfortable. drill_id: hit_08 drill_review: needs_coach_review +- metric_id: torso_inclination_at_stride_start + display_name: Torso Inclination at Stride Start + group: balance_load + unit: deg + reference: torso_angle_from_vertical + event_id: stride_start + mirror_for_left: false + what_it_means: How far your torso leans from upright when your stride begins. + in_range_text: Your torso lean when your stride began was within the reference range. + directions: + above: + meaning: torso_inclination_at_stride_start_above + result_text: + satisfactory: Your torso lean when your stride began was above the reference range. + off_target: Your torso lean when your stride began was above the reference range. + headline: Your torso lean when your stride began was above the reference range. + coach_message: Your torso lean when your stride began was above the reference range. Use a comfortable swing and + keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_04 + drill_review: reference_comparison_only + below: + meaning: torso_inclination_at_stride_start_below + result_text: + satisfactory: Your torso lean when your stride began was below the reference range. + off_target: Your torso lean when your stride began was below the reference range. + headline: Your torso lean when your stride began was below the reference range. + coach_message: Your torso lean when your stride began was below the reference range. Use a comfortable swing and + keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_04 + drill_review: reference_comparison_only + maintain: + coach_message: Your torso lean when your stride began was within the reference range. Keep your movement smooth and + repeatable. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_04 + drill_review: reference_comparison_only +- metric_id: hip_shoulder_separation_at_stride_start + display_name: Hip Shoulder Separation at Stride Start + group: balance_load + unit: deg + reference: signed_horizontal_shoulder_minus_hip_heading + event_id: stride_start + mirror_for_left: false + what_it_means: The angle between your hips and shoulders when your stride begins. + in_range_text: Your hip and shoulder angle when your stride began was within the reference range. + directions: + above: + meaning: hip_shoulder_separation_at_stride_start_above + result_text: + satisfactory: Your hip and shoulder angle when your stride began was above the reference range. + off_target: Your hip and shoulder angle when your stride began was above the reference range. + headline: Your hip and shoulder angle when your stride began was above the reference range. + coach_message: Your hip and shoulder angle when your stride began was above the reference range. Use a comfortable + swing and keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_04 + drill_review: reference_comparison_only + below: + meaning: hip_shoulder_separation_at_stride_start_below + result_text: + satisfactory: Your hip and shoulder angle when your stride began was below the reference range. + off_target: Your hip and shoulder angle when your stride began was below the reference range. + headline: Your hip and shoulder angle when your stride began was below the reference range. + coach_message: Your hip and shoulder angle when your stride began was below the reference range. Use a comfortable + swing and keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_04 + drill_review: reference_comparison_only + maintain: + coach_message: Your hip and shoulder angle when your stride began was within the reference range. Keep your movement + smooth and repeatable. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_04 + drill_review: reference_comparison_only +- metric_id: pelvis_rotation_to_contact + display_name: Hip Turn to Contact + group: power_move + unit: deg + reference: absolute_net_horizontal_rotation + start_event_id: front_foot_down + end_event_id: contact + mirror_for_left: false + what_it_means: How far your hips turn between front foot touch and contact. + in_range_text: Your hip turn from foot touch to contact was within the reference range. + directions: + above: + meaning: pelvis_rotation_to_contact_above + result_text: + satisfactory: Your hip turn from foot touch to contact was above the reference range. + off_target: Your hip turn from foot touch to contact was above the reference range. + headline: Your hip turn from foot touch to contact was above the reference range. + coach_message: Your hip turn from foot touch to contact was above the reference range. Use a comfortable swing + and keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_14 + drill_review: reference_comparison_only + below: + meaning: pelvis_rotation_to_contact_below + result_text: + satisfactory: Your hip turn from foot touch to contact was below the reference range. + off_target: Your hip turn from foot touch to contact was below the reference range. + headline: Your hip turn from foot touch to contact was below the reference range. + coach_message: Your hip turn from foot touch to contact was below the reference range. Use a comfortable swing + and keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_14 + drill_review: reference_comparison_only + maintain: + coach_message: Your hip turn from foot touch to contact was within the reference range. Keep your movement smooth + and repeatable. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_14 + drill_review: reference_comparison_only +- metric_id: lead_knee_extension_to_contact + display_name: Front Knee Extension to Contact + group: power_move + unit: deg + reference: change_in_3d_lead_knee_angle + start_event_id: front_foot_down + end_event_id: contact + mirror_for_left: false + what_it_means: How much your front knee straightens between foot touch and contact. + in_range_text: Your front knee straightening from foot touch to contact was within the reference range. + directions: + above: + meaning: lead_knee_extension_to_contact_above + result_text: + satisfactory: Your front knee straightening from foot touch to contact was above the reference range. + off_target: Your front knee straightening from foot touch to contact was above the reference range. + headline: Your front knee straightening from foot touch to contact was above the reference range. + coach_message: Your front knee straightening from foot touch to contact was above the reference range. Use a comfortable + swing and keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_14 + drill_review: reference_comparison_only + below: + meaning: lead_knee_extension_to_contact_below + result_text: + satisfactory: Your front knee straightening from foot touch to contact was below the reference range. + off_target: Your front knee straightening from foot touch to contact was below the reference range. + headline: Your front knee straightening from foot touch to contact was below the reference range. + coach_message: Your front knee straightening from foot touch to contact was below the reference range. Use a comfortable + swing and keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_14 + drill_review: reference_comparison_only + maintain: + coach_message: Your front knee straightening from foot touch to contact was within the reference range. Keep your + movement smooth and repeatable. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_14 + drill_review: reference_comparison_only +- metric_id: torso_inclination_at_contact + display_name: Torso Inclination at Contact + group: contact_follow_through + unit: deg + reference: torso_angle_from_vertical + event_id: contact + mirror_for_left: false + what_it_means: How far your torso leans from upright at contact. + in_range_text: Your torso lean at contact was within the reference range. + directions: + above: + meaning: torso_inclination_at_contact_above + result_text: + satisfactory: Your torso lean at contact was above the reference range. + off_target: Your torso lean at contact was above the reference range. + headline: Your torso lean at contact was above the reference range. + coach_message: Your torso lean at contact was above the reference range. Use a comfortable swing and keep the movement + repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_08 + drill_review: reference_comparison_only + below: + meaning: torso_inclination_at_contact_below + result_text: + satisfactory: Your torso lean at contact was below the reference range. + off_target: Your torso lean at contact was below the reference range. + headline: Your torso lean at contact was below the reference range. + coach_message: Your torso lean at contact was below the reference range. Use a comfortable swing and keep the movement + repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_08 + drill_review: reference_comparison_only + maintain: + coach_message: Your torso lean at contact was within the reference range. Keep your movement smooth and repeatable. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_08 + drill_review: reference_comparison_only +- metric_id: shoulder_rotation_after_contact + display_name: Early Follow-Through Shoulder Turn + group: contact_follow_through + unit: deg + reference: absolute_net_horizontal_rotation + start_event_id: contact + end_event_id: follow_through + mirror_for_left: false + what_it_means: How far your shoulders turn during the first tenth of a second after contact. + in_range_text: Your shoulder turn just after contact was within the reference range. + directions: + above: + meaning: shoulder_rotation_after_contact_above + result_text: + satisfactory: Your shoulder turn just after contact was above the reference range. + off_target: Your shoulder turn just after contact was above the reference range. + headline: Your shoulder turn just after contact was above the reference range. + coach_message: Your shoulder turn just after contact was above the reference range. Use a comfortable swing and + keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_08 + drill_review: reference_comparison_only + below: + meaning: shoulder_rotation_after_contact_below + result_text: + satisfactory: Your shoulder turn just after contact was below the reference range. + off_target: Your shoulder turn just after contact was below the reference range. + headline: Your shoulder turn just after contact was below the reference range. + coach_message: Your shoulder turn just after contact was below the reference range. Use a comfortable swing and + keep the movement repeatable. + coach_tip: Practice a comfortable, repeatable swing. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_08 + drill_review: reference_comparison_only + maintain: + coach_message: Your shoulder turn just after contact was within the reference range. Keep your movement smooth and + repeatable. + practice_feel: Keep your movement smooth and comfortable. + drill_id: hit_08 + drill_review: reference_comparison_only + # The practice suggestion when nothing in the swing could be rated, so the player always has a drill. general_focus: display_name: General practice @@ -201,6 +444,16 @@ reasons: limitation: The movement did not line up from frame to frame, so treat this as approximate. report: The movement did not line up from frame to frame, so some results are approximate. + capture_time_unknown: + limitation: We do not know the true speed of this clip. + report: We do not know the true clip speed, so we cannot time the finish. + follow_through_not_recorded: + limitation: The clip ends too soon after the hit. + report: The clip ends too soon for us to check the turn after the hit. + model_accuracy_unvalidated: + limitation: Body points are estimates. We have not checked them against true body positions. + report: Scores come from estimated body points. Treat them as rough guides. + # data_quality notes the coach adds itself (not from the payload). notes: level_assumed: diff --git a/AI-coach-agent/src/ai_coach/swing_report/schemas.py b/AI-coach-agent/src/ai_coach/swing_report/schemas.py index d520b289afed3d2c7c3d7e904f1909f64d1bc7d1..901ea93b7d8fe3658277d5b9ca7a143fd0b0a930 100644 --- a/AI-coach-agent/src/ai_coach/swing_report/schemas.py +++ b/AI-coach-agent/src/ai_coach/swing_report/schemas.py @@ -11,8 +11,8 @@ from typing import Annotated, Literal from pydantic import BaseModel, ConfigDict, Field, StringConstraints -SCHEMA_VERSION = "1.0" -MEASUREMENT_DEFINITIONS_VERSION = "1.0" +SCHEMA_VERSION = "1.1" +MEASUREMENT_DEFINITIONS_VERSION = "1.1" REPORT_SCHEMA_VERSION = "1.0" Side = Literal["left", "right"] @@ -20,21 +20,28 @@ PracticeType = Literal["tee", "front_toss", "side_toss", "pitching_machine", "li MeasurementGroup = Literal["balance_load", "stride", "power_move", "contact_follow_through"] ResultStatus = Literal["available", "limited", "unavailable"] MeasurementUnit = Literal["deg", "cm"] -EventId = Literal["stride_start", "front_foot_down", "contact"] -EventSource = Literal["manual_review", "pose_estimated", "bat_ball_detector"] -MetricId = Literal["hip_shoulder_separation_at_foot_down", "stride_relative_length", "hip_shoulder_separation_at_contact"] -MeasurementReference = Literal["signed_horizontal_shoulder_minus_hip_heading", "lead_ankle_displacement_relative_to_rear_ankle"] +EventId = Literal["stride_start", "front_foot_down", "contact", "follow_through"] +EventSource = Literal["manual_review", "pose_estimated", "bat_ball_detector", "derived_from_contact"] +MetricId = Literal["hip_shoulder_separation_at_foot_down", "stride_relative_length", "hip_shoulder_separation_at_contact", + "torso_inclination_at_stride_start", "hip_shoulder_separation_at_stride_start", + "pelvis_rotation_to_contact", "lead_knee_extension_to_contact", "torso_inclination_at_contact", + "shoulder_rotation_after_contact"] +MeasurementReference = Literal["signed_horizontal_shoulder_minus_hip_heading", "lead_ankle_displacement_relative_to_rear_ankle", + "torso_angle_from_vertical", "absolute_net_horizontal_rotation", "change_in_3d_lead_knee_angle"] ReasonCode = Literal[ "contact_not_verified", "contact_not_applicable", "event_not_detected", "event_timing_uncertain", "required_event_unavailable", "required_event_limited", "lead_foot_unknown", "required_landmarks_unusable", "ground_plane_unknown", "scale_is_model_estimated", "scale_unknown", "excessive_interpolation", - "occlusion_unresolved", "temporal_inconsistency", + "occlusion_unresolved", "temporal_inconsistency", "capture_time_unknown", "follow_through_not_recorded", + "model_accuracy_unvalidated", ] # fmt: skip GROUP_ORDER: tuple[str, ...] = ("balance_load", "stride", "power_move", "contact_follow_through") EVENT_IDS: tuple[str, ...] = ("stride_start", "front_foot_down", "contact") -METRIC_IDS: tuple[str, ...] = ("hip_shoulder_separation_at_foot_down", "stride_relative_length", - "hip_shoulder_separation_at_contact") +LEGACY_METRIC_IDS = ("hip_shoulder_separation_at_foot_down", "stride_relative_length", "hip_shoulder_separation_at_contact") +METRIC_IDS: tuple[str, ...] = (*LEGACY_METRIC_IDS, "torso_inclination_at_stride_start", + "hip_shoulder_separation_at_stride_start", "pelvis_rotation_to_contact", "lead_knee_extension_to_contact", + "torso_inclination_at_contact", "shoulder_rotation_after_contact") NonEmptyStr = Annotated[str, StringConstraints(min_length=1, pattern=r"\S")] @@ -62,12 +69,20 @@ class SwingEvent(_Input): capture_time_s: float | None source: EventSource | None reasons: list[ReasonCode] = Field(default_factory=list) # optional only for available events + source_frame_index: int | None = Field(default=None, ge=0) class Events(_Input): stride_start: SwingEvent front_foot_down: SwingEvent contact: SwingEvent + follow_through: SwingEvent | None = None + + +class ValueInterval(_Input): + lower: float + upper: float + source: Literal["adjacent_event_frames"] class ApprovedBenchmark(_Input): @@ -94,17 +109,18 @@ class Measurement(_Input): uses_interpolated_input: bool reasons: list[ReasonCode] benchmark: ApprovedBenchmark | None + value_interval: ValueInterval | None = None class SwingAnalysisPayload(_Input): - schema_version: Literal["1.0"] + schema_version: Literal["1.0", "1.1"] analysis_id: NonEmptyStr analysis_revision: int = Field(ge=1) swing_id: NonEmptyStr status: Literal["completed"] athlete: Athlete context: SwingContext - measurement_definitions_version: Literal["1.0"] + measurement_definitions_version: Literal["1.0", "1.1"] events: Events measurements: list[Measurement] = Field(min_length=1) @@ -199,6 +215,8 @@ class MeasurementReport(_Output): result_text: str | None coach_tip: str | None limitations: list[Limitation] + value_interval: Interval | None = None + score_interval: Interval | None = None class DataQualityNote(_Output): diff --git a/AI-coach-agent/src/ai_coach/swing_report/service.py b/AI-coach-agent/src/ai_coach/swing_report/service.py index 58b2c53ac8d933e74d214761822560ad4a1e2b38..ef31206d0ba66cbf3dbb6e3f4ea431306beb6e5b 100644 --- a/AI-coach-agent/src/ai_coach/swing_report/service.py +++ b/AI-coach-agent/src/ai_coach/swing_report/service.py @@ -13,7 +13,7 @@ from typing import Any, Literal from ..config import Settings, get_settings from . import repository as repo -from .schemas import REPORT_SCHEMA_VERSION, SCHEMA_VERSION, SwingAnalysisPayload, SwingReport +from .schemas import REPORT_SCHEMA_VERSION, SwingAnalysisPayload, SwingReport from .scoring import NOT_RATED, ON_TARGET, RATING_LABELS, mean_score, rating_for, round_half_up, score, side_of from .text import PROMPT_VERSION, Generator, model_facts, write_texts from .validation import validate_payload @@ -71,6 +71,9 @@ def _rate_measurement(metric: dict, m, hand: str | None, athlete: AthleteContext "score": None, "rating": NOT_RATED, "rating_label": "", "rating_is_tentative": False, "not_rated_reason": None, "benchmark": None, "what_it_means": metric["what_it_means"], "result_text": None, "coach_tip": None, "limitations": [{"code": r, "text": repo.reason_text(r)["limitation"]} for r in dict.fromkeys(m.reasons)], + "value_interval": None if m.value_interval is None else { + "lower": m.value_interval.lower, "upper": m.value_interval.upper}, + "score_interval": None, } side = None if m.status == "unavailable" or m.value is None: @@ -83,6 +86,12 @@ def _rate_measurement(metric: dict, m, hand: str | None, athlete: AthleteContext out["score"] = score(m.value, b.on_lower, b.on_upper, b.sat_lower, b.sat_upper) out["rating"] = rating_for(out["score"]) out["rating_is_tentative"] = m.status == "limited" + if m.value_interval is not None: + low, high = m.value_interval.lower, m.value_interval.upper + candidates = [low, high, m.value] + candidates += [v for v in (b.on_lower, b.on_upper, b.sat_lower, b.sat_upper) if low <= v <= high] + scores = [score(v, b.on_lower, b.on_upper, b.sat_lower, b.sat_upper) for v in candidates] + out["score_interval"] = {"lower": min(scores), "upper": max(scores)} raw_side = side_of(m.value, b.on_lower, b.on_upper) # Coaching direction is normalised: mirrored metrics flip for left-handed hitters (see swing_metrics.yaml). if raw_side and metric["mirror_for_left"] and hand == "left": @@ -115,12 +124,16 @@ def build_report(payload: dict, athlete: AthleteContext | None = None, *, settin athlete = athlete or AthleteContext() settings = settings or get_settings() hand, hand_inferred = resolve_batting_hand(parsed, athlete) + hand_conflict = bool(parsed.athlete.batting_hand and athlete.batting_hand and + parsed.athlete.batting_hand != athlete.batting_hand) notes: list[str] = [] measurements: list[dict] = [] sides: dict[str, str | None] = {} for metric in repo.metrics(): m = parsed.measurement(metric["metric_id"]) + if m is None: + continue # old payloads do not acquire invented new measurements out, sides[metric["metric_id"]] = _rate_measurement(metric, m, hand, athlete, notes) measurements.append(out) by_id = {m["metric_id"]: m for m in measurements} @@ -148,7 +161,23 @@ def build_report(payload: dict, athlete: AthleteContext | None = None, *, settin }) overall = mean_score(g["score"] for g in groups) overall_tentative = any(g["score_is_tentative"] for g in groups if g["score"] is not None) - focus = _choose_focus(measurements, sides) + context_unverified = parsed.context.practice_type in ("unknown", "dry_swing") + sensitive = {m["metric_id"] for m in measurements if m["score_interval"] is not None and ( + m["score_interval"]["upper"] - m["score_interval"]["lower"] >= 20 or + rating_for(m["score_interval"]["lower"]) != rating_for(m["score_interval"]["upper"]))} + eligible = [] if context_unverified or hand_conflict else [m for m in measurements if m["metric_id"] not in sensitive] + focus = _choose_focus(eligible, sides) + if focus["kind"] == "maintain" and any(m["metric_id"] in sensitive and m["rating"] != ON_TARGET for m in measurements): + focus = _choose_focus([], sides) + if hand_conflict: + focus["coach_message"] = "The swing and profile list different batting sides. Check the side before using these scores to change your swing." + elif context_unverified: + focus["coach_message"] = "These results describe your measured movement. The drill context does not support a technique correction." + focus["practice_feel"] = "Keep your practice comfortable and repeatable." + elif sensitive and focus["kind"] == "general": + focus["coach_message"] = "The results change with the marked swing moments. Treat them as approximate before changing your swing." + if focus["is_tentative"]: + focus["coach_message"] = "This result is an estimate. " + focus["coach_message"] # Rules text for every field, then the subset the model may reword. rules: dict[str, str | None] = {} @@ -156,6 +185,16 @@ def build_report(payload: dict, athlete: AthleteContext | None = None, *, settin tips_wanted: set[str] = set() for m in measurements: result_text, tip = _rules_result(repo.metric_info(m["metric_id"]), m["rating"], sides[m["metric_id"]]) + if context_unverified or hand_conflict or m["metric_id"] in sensitive: + tip = None + if m["score"] is not None: + subject = m["display_name"].lower() + b = m["benchmark"]["on_target"] + position = "within" if b["lower"] <= m["value"] <= b["upper"] else ( + "above" if m["value"] > b["upper"] else "below") + result_text = f"Your estimated {subject} was {position} the reference range." + elif result_text is not None and m["rating_is_tentative"]: + result_text = "This result is approximate. " + result_text m["result_text"], m["coach_tip"] = result_text, tip findings[m["metric_id"]] = result_text if result_text is not None: @@ -177,6 +216,8 @@ def build_report(payload: dict, athlete: AthleteContext | None = None, *, settin headline = repo.text("headline_all_on_target") else: headline = repo.text("headline_nothing_rated") + if any(m["score"] is not None for m in measurements): + headline = "Your results are reference comparisons. There is not enough evidence to choose a technique correction." if overall_tentative and focus["kind"] != "general": headline = f"{headline} {repo.text('headline_tentative')}" rules["coach_message"] = focus["coach_message"] @@ -189,9 +230,24 @@ def build_report(payload: dict, athlete: AthleteContext | None = None, *, settin "data_quality": _data_quality(parsed, measurements, notes, hand, hand_inferred), } + if context_unverified: + report["data_quality"].append({"code": "practice_context_unverified", "severity": "warning", + "text": "The drill context does not match a verified reference task. Scores are comparisons, not technique diagnoses."}) + if hand_conflict: + report["data_quality"].append({"code": "batting_hand_conflict", "severity": "warning", + "text": "The analysis and athlete profile list different batting sides. Scores use the analysis side; verify it before interpreting them."}) + if sensitive: + report["data_quality"].append({"code": "event_sensitive_scores", "severity": "warning", + "text": "Some ratings change when an event moves by one frame. Score ranges show that sensitivity, not total measurement error."}) + if len([g for g in groups if g["score"] is not None]) < len(groups): + report["data_quality"].append({"code": "partial_group_coverage", "severity": "warning", + "text": "The overall score uses only groups with scored measurements. It is not a complete assessment of every swing phase."}) + if any(k.startswith("result:") for k in rules): # something rated: let the model word it rules["headline"] = headline facts = model_facts(report, findings, subjects, tips_wanted, groups_wanted) + facts["practice_type"] = parsed.context.practice_type + facts["technique_correction_supported"] = not context_unverified and not hand_conflict and focus["kind"] != "general" result = write_texts(facts, rules, settings, generator=generator, request_id=request_id) texts = result.texts report["overview"]["headline"] = texts["headline"] @@ -210,7 +266,7 @@ def build_report(payload: dict, athlete: AthleteContext | None = None, *, settin report["meta"] = { "generated_at": (now or datetime.now(UTC)).astimezone(UTC).strftime("%Y-%m-%dT%H:%M:%SZ"), "request_id": request_id, **text_meta, "prompt_version": PROMPT_VERSION, - "input_schema_version": SCHEMA_VERSION, "measurement_definitions_version": parsed.measurement_definitions_version, + "input_schema_version": parsed.schema_version, "measurement_definitions_version": parsed.measurement_definitions_version, "benchmark_registry_version": repo.benchmark_version(), "coaching_rules_version": repo.coaching_rules_version(), } return SwingReport.model_validate(report).model_dump(mode="json") @@ -263,7 +319,11 @@ def _rules_group_summary(g: dict, by_id: dict[str, dict]) -> str: if reason == "no_rated_measurements": return repo.text("group_not_rated") if g["rating"] == ON_TARGET: - return repo.text("group_on_target") + rated = [m for m in members if m["score"] is not None] + if len(rated) == 1: + return rated[0]["result_text"] + qualifier = "estimated " if g["score_is_tentative"] else "" + return f"These {qualifier}results were in the usual range for the measured moves." rated = [m for m in members if m["score"] is not None] worst = min(rated, key=lambda m: m["score"]) return worst["result_text"] or repo.text("group_on_target") diff --git a/AI-coach-agent/src/ai_coach/swing_report/text.py b/AI-coach-agent/src/ai_coach/swing_report/text.py index 174b55781904b1af802f00911ceea55736d2f454..292cfd990434da7302bcd7327b379213b397d7cc 100644 --- a/AI-coach-agent/src/ai_coach/swing_report/text.py +++ b/AI-coach-agent/src/ai_coach/swing_report/text.py @@ -40,6 +40,13 @@ Rules for every string you write: measurements, contact, injuries, pain, health advice, scores or promises of improvement. - Do not use judgement words such as good, bad, great, perfect, poor, wrong or mistake. - Keep each finding's meaning exactly. For on_target results say the movement is in the typical range. +- A group name is a navigation label, not evidence that every part of that group was measured. Discuss only the + listed metric_ids. Only shoulder_rotation_after_contact measures any follow-through, and only its early shoulder turn. +- Preserve uncertainty: every approximate finding and group summary must say estimated, approximate or uncertain. +- When technique_correction_supported is false, describe the reference comparison without telling the player to + shorten, lengthen or change their mechanics. Do not diagnose a drill-specific movement as a fault. +- No claims about power, energy, force, bat speed, ball flight or the quality of the whole swing. +- A single hip-shoulder angle does not establish when the shoulders began opening. Do not call it early or late. Fields: - headline: at most twenty-five words. If the focus kind is "fix", name the focus group as the area to work on and say @@ -125,7 +132,7 @@ def gemini_generator(settings: Settings) -> Generator: response = client.models.generate_content( model=settings.model, contents=prompt, config=types.GenerateContentConfig( - temperature=settings.temperature, max_output_tokens=max(settings.max_output_tokens, 1200), + temperature=settings.temperature, max_output_tokens=max(settings.max_output_tokens, 3000), response_mime_type="application/json", response_json_schema=schema, thinking_config=thinking), ) u = response.usage_metadata @@ -204,7 +211,40 @@ def _parse(raw: str, rules: dict[str, str | None], facts: dict) -> dict[str, str return out -def _merge(candidate: dict[str, str], rules: dict[str, str | None]) -> tuple[dict[str, str | None], int, dict]: +def semantic_problems(text: str, key: str, facts: dict) -> list[str]: + """Reject known scope/rating/uncertainty violations before wording reaches a player.""" + rows = {m["metric_id"]: m for m in facts.get("measurements", [])} + group = next((g for g in facts.get("groups", []) if key == "group:" + g["group"]), None) + ids = group["metric_ids"] if group else ([key.split(":", 1)[1]] if key.startswith(("result:", "tip:")) else list(rows)) + selected = [rows[k] for k in ids if k in rows] + problems = [] + t = text.lower() + if re.search(r"follow[ -]?through|finish(?:ing)? (?:position|movement)", t): + if "shoulder_rotation_after_contact" not in ids: + problems.append("unmeasured_follow_through") + elif not re.search(r"early shoulder turn|shoulder turn just after", t) or re.search(r"whole|entire|complete", t): + problems.append("follow_through_scope_exceeded") + if re.search(r"\b(?:power|energy|force|exit velocity|bat speed|ball flight|bat path)\b", t): + problems.append("unsupported_physical_claim") + if re.search(r"shoulder.*(?:early|late|before.*(?:foot|land))", t): + problems.append("unsupported_shoulder_timing") + approximate = any(m.get("approximate") for m in selected) + if approximate and not key.startswith("tip:") and not re.search(r"\b(?:approximate|estimate[ds]?|uncertain|appears?)\b", t): + problems.append("uncertainty_removed") + rating = group["rating"] if group else (selected[0]["rating"] if len(selected) == 1 else None) + if rating not in (None, "on_target") and re.search(r"typical range|on target|everything.*(?:range|normal)", t): + problems.append("rating_changed") + if len(selected) == 1: + finding = (selected[0].get("finding") or "").lower() + if ("above the reference" in finding and "below" in t) or ("below the reference" in finding and "above" in t): + problems.append("direction_changed") + if facts.get("technique_correction_supported") is False and re.search( + r"\b(?:shorten|shorter|lengthen|longer|reduce|increase|fix|correct|too long|too short|turn earlier|turn later)\b", t): + problems.append("unsupported_technique_correction") + return problems + + +def _merge(candidate: dict[str, str], rules: dict[str, str | None], facts: dict | None = None) -> tuple[dict[str, str | None], int, dict]: texts: dict[str, str | None] = {} used, rejected = 0, {} for key, rule_text in rules.items(): @@ -213,6 +253,10 @@ def _merge(candidate: dict[str, str], rules: dict[str, str | None]) -> tuple[dic texts[key] = None # nothing is wanted here (e.g. no tip for an on-target measurement) continue problems = check_text(text, _kind(key)) if text is not None else ["missing"] + if text is not None and facts is not None: + problems += semantic_problems(text, key, facts) + if rule_text is None and (text or "").strip(): + problems.append("unrequested_advice") if problems: texts[key] = rule_text rejected[key] = problems @@ -234,6 +278,9 @@ def write_texts(facts: dict, rules: dict[str, str | None], settings: Settings, * `rules` holds the fixed-rule text for each field the model may write; `facts` is what the model sees. """ + if facts.get("technique_correction_supported") is False: + # An unknown drill or an unstable score does not support free-form technique advice. + return TextResult(dict(rules), "rules", fallback_reason="insufficient_coaching_context") if generator is None and not settings.llm_enabled: return TextResult(dict(rules), "rules", fallback_reason="llm_not_configured") generate = generator or gemini_generator(settings) @@ -244,7 +291,7 @@ def write_texts(facts: dict, rules: dict[str, str | None], settings: Settings, * request_id = request_id or uuid.uuid4().hex[:12] def finish(raw: str, cache_hit: bool) -> TextResult: - texts, used, rejected = _merge(_parse(raw, rules, facts), rules) + texts, used, rejected = _merge(_parse(raw, rules, facts), rules, facts) if rejected: log.info("swing report text: %d field(s) replaced by rules: %s", len(rejected), rejected) source = "llm" if not rejected else ("rules" if used == 0 else "mixed") @@ -302,7 +349,8 @@ def model_facts(report: dict[str, Any], findings: dict[str, str | None], subject for m in report["measurements"] if m["rating"] != "not_rated" ] groups = [ - {"group": g["group"], "name": g["display_name"], "rating": g["rating"], "metric_ids": g["metric_ids"]} + {"group": g["group"], "name": "Measured movements", "rating": g["rating"], "metric_ids": g["metric_ids"], + "approximate": g["score_is_tentative"]} for g in report["groups"] if g["group"] in groups_wanted ] focus = report.get("focus_area") diff --git a/AI-coach-agent/src/ai_coach/swing_report/validation.py b/AI-coach-agent/src/ai_coach/swing_report/validation.py index 9b74c4c5525d5022c6c77aa73373a63d63cbe6eb..79b58970e9d5be370debfc6fe9807c84607d0c40 100644 --- a/AI-coach-agent/src/ai_coach/swing_report/validation.py +++ b/AI-coach-agent/src/ai_coach/swing_report/validation.py @@ -14,8 +14,8 @@ from typing import Any from pydantic import ValidationError from .schemas import ( - MEASUREMENT_DEFINITIONS_VERSION, METRIC_IDS, + LEGACY_METRIC_IDS, SCHEMA_VERSION, Measurement, SwingAnalysisPayload, @@ -35,8 +35,21 @@ METRIC_SPECS: dict[str, dict[str, Any]] = { "hip_shoulder_separation_at_contact": { "group": "contact_follow_through", "unit": "deg", "reference": "signed_horizontal_shoulder_minus_hip_heading", "event_id": "contact"}, + "torso_inclination_at_stride_start": {"group": "balance_load", "unit": "deg", + "reference": "torso_angle_from_vertical", "event_id": "stride_start"}, + "hip_shoulder_separation_at_stride_start": {"group": "balance_load", "unit": "deg", + "reference": "signed_horizontal_shoulder_minus_hip_heading", "event_id": "stride_start"}, + "pelvis_rotation_to_contact": {"group": "power_move", "unit": "deg", + "reference": "absolute_net_horizontal_rotation", "start_event_id": "front_foot_down", "end_event_id": "contact"}, + "lead_knee_extension_to_contact": {"group": "power_move", "unit": "deg", + "reference": "change_in_3d_lead_knee_angle", "start_event_id": "front_foot_down", "end_event_id": "contact"}, + "torso_inclination_at_contact": {"group": "contact_follow_through", "unit": "deg", + "reference": "torso_angle_from_vertical", "event_id": "contact"}, + "shoulder_rotation_after_contact": {"group": "contact_follow_through", "unit": "deg", + "reference": "absolute_net_horizontal_rotation", "start_event_id": "contact", "end_event_id": "follow_through"}, } # fmt: skip -SEPARATION_METRICS = ("hip_shoulder_separation_at_foot_down", "hip_shoulder_separation_at_contact") +SEPARATION_METRICS = ("hip_shoulder_separation_at_foot_down", "hip_shoulder_separation_at_contact", + "hip_shoulder_separation_at_stride_start") SCOPE_FIELDS = ("event_id", "start_event_id", "end_event_id") USABLE = ("available", "limited") @@ -61,7 +74,7 @@ def _message(err: dict) -> str: if kind == "missing": return "This field is required." if kind == "extra_forbidden": - return "This field is not part of contract 1.0." + return "This field is not part of the swing analysis contract." if kind == "finite_number": return "Must be a finite number." msg = str(err.get("msg", "Invalid value.")) @@ -73,11 +86,10 @@ def validate_payload(raw: Any) -> tuple[SwingAnalysisPayload | None, Problems]: return None, {"payload": "Must be a JSON object."} problems: Problems = {} # Rule 1 first, with a clear message: another version may have a different shape altogether. - if raw.get("schema_version") != SCHEMA_VERSION: - problems["schema_version"] = f'Only contract version "{SCHEMA_VERSION}" is supported.' - if raw.get("measurement_definitions_version") != MEASUREMENT_DEFINITIONS_VERSION: - problems["measurement_definitions_version"] = ( - f'Only measurement definitions version "{MEASUREMENT_DEFINITIONS_VERSION}" is supported.') + if raw.get("schema_version") not in ("1.0", SCHEMA_VERSION): + problems["schema_version"] = 'Supported contract versions are "1.0" and "1.1".' + elif raw.get("measurement_definitions_version") != raw.get("schema_version"): + problems["measurement_definitions_version"] = 'Measurement definitions must match contract "1.0" or "1.1".' if problems: return None, problems try: @@ -97,6 +109,10 @@ def check_rules(p: SwingAnalysisPayload, problems: Problems) -> None: events: dict[str, SwingEvent] = {"stride_start": p.events.stride_start, "front_foot_down": p.events.front_foot_down, "contact": p.events.contact} + if p.events.follow_through is not None: + events["follow_through"] = p.events.follow_through + elif p.schema_version == "1.1": + add("events.follow_through", "Contract 1.1 requires a follow-through event, including an unavailable event.") # Rule 3: exactly one entry per registered metric. seen: dict[str, int] = {} @@ -104,9 +120,12 @@ def check_rules(p: SwingAnalysisPayload, problems: Problems) -> None: if m.metric_id in seen: add(f"measurements[{i}].metric_id", "Duplicate metric id: each metric must appear once.") seen.setdefault(m.metric_id, i) - missing = [k for k in METRIC_IDS if k not in seen] + expected = LEGACY_METRIC_IDS if p.schema_version == "1.0" else METRIC_IDS + missing = [k for k in expected if k not in seen] if missing: add("measurements", "Missing measurements: " + ", ".join(missing) + ".") + if set(seen) - set(expected): + add("measurements", "Measurements must match the declared contract version.") # Rules 5, 6 and 8 on events. for name, ev in events.items(): @@ -134,6 +153,12 @@ def check_rules(p: SwingAnalysisPayload, problems: Problems) -> None: add(f"{base}.source", "Pose estimation cannot establish contact.") if ev.source == "bat_ball_detector" and name != "contact": add(f"{base}.source", "The bat-ball detector is valid only for the contact event.") + if ev.source == "derived_from_contact" and name != "follow_through": + add(f"{base}.source", "Only follow-through may be derived from contact.") + if ev.status == "unavailable" and ev.source_frame_index is not None: + add(f"{base}.source_frame_index", "An unavailable event cannot have a source frame.") + if p.schema_version == "1.1" and ev.status in USABLE and ev.source_frame_index is None: + add(f"{base}.source_frame_index", "Contract 1.1 requires the decoded source frame index.") start, landing, contact = events["stride_start"], events["front_foot_down"], events["contact"] if (start.status in USABLE and landing.status in USABLE and start.video_time_s is not None @@ -142,6 +167,23 @@ def check_rules(p: SwingAnalysisPayload, problems: Problems) -> None: if (landing.status == "available" and contact.status == "available" and landing.video_time_s is not None and contact.video_time_s is not None and landing.video_time_s > contact.video_time_s): add("events.front_foot_down.video_time_s", "Must be before contact when both are available.") + finish = events.get("follow_through") + if finish and finish.status in USABLE and (contact.status not in USABLE or + finish.video_time_s is None or contact.video_time_s is None or finish.video_time_s <= contact.video_time_s): + add("events.follow_through.video_time_s", "Follow-through must follow usable contact.") + if p.schema_version == "1.1": + for earlier, later in (("stride_start", "front_foot_down"), ("front_foot_down", "contact"), + ("contact", "follow_through")): + a, b = events.get(earlier), events.get(later) + if a is None or b is None or a.status not in USABLE or b.status not in USABLE: + continue + for field in ("source_frame_index", "video_time_s", "capture_time_s"): + av, bv = getattr(a, field), getattr(b, field) + if av is not None and bv is not None and (av > bv or (av == bv and earlier != "front_foot_down")): + add(f"events.{earlier}.{field}", f"Must be before {later}." if earlier != "front_foot_down" + else "Must not be after contact.") + if finish and finish.status in USABLE and (finish.capture_time_s is None or contact.capture_time_s is None): + add("events.follow_through.capture_time_s", "Timed follow-through requires a known capture clock.") for i, m in enumerate(p.measurements): _check_measurement(i, m, events, p, add) @@ -178,6 +220,9 @@ def _check_measurement(i: int, m: Measurement, events: dict[str, SwingEvent], p: # Rule 7: event quality propagates. for event_id in required_events(m.metric_id): + if event_id not in events: + add(f"{base}.status", f"Missing required event: {event_id}.") + continue status = events[event_id].status if status == "unavailable" and m.status != "unavailable": add(f"{base}.status", f"Must be unavailable because {event_id} is unavailable.") @@ -190,7 +235,7 @@ def _check_measurement(i: int, m: Measurement, events: dict[str, SwingEvent], p: add(f"{base}.status", "Must be unavailable when the scale is unknown.") if "scale_is_model_estimated" in m.reasons and m.status == "unavailable" and m.reasons == ["scale_is_model_estimated"]: add(f"{base}.status", "A model-estimated scale needs status limited, not unavailable.") - if m.metric_id == "stride_relative_length": + if m.metric_id in ("stride_relative_length", "lead_knee_extension_to_contact"): if p.athlete.lead_foot is None: if m.status != "unavailable": add(f"{base}.status", "Must be unavailable when the lead foot is unknown.") @@ -205,6 +250,16 @@ def _check_measurement(i: int, m: Measurement, events: dict[str, SwingEvent], p: add(f"{base}.value", "Separation must be from -180 up to but not including 180 degrees.") if m.metric_id == "stride_relative_length" and m.value < 0: add(f"{base}.value", "Stride length must not be negative.") + if m.reference in ("torso_angle_from_vertical", "absolute_net_horizontal_rotation") and m.value < 0: + add(f"{base}.value", "An angle magnitude cannot be negative.") + if m.reference == "torso_angle_from_vertical" and m.value >= 90: + add(f"{base}.value", "Torso inclination requires an upright torso.") + if m.reference == "change_in_3d_lead_knee_angle" and not -180 <= m.value <= 180: + add(f"{base}.value", "Knee extension must be between minus and plus 180 degrees.") + if m.value_interval is not None: + interval = m.value_interval + if m.value is None or not interval.lower <= m.value <= interval.upper: + add(f"{base}.value_interval", "The interval must be ordered and contain the measurement value.") # Rule 11: an optional benchmark must be coherent (the coach uses its own ranges either way). b = m.benchmark diff --git a/AI-coach-agent/tests/test_swing_report_evidence_scope.py b/AI-coach-agent/tests/test_swing_report_evidence_scope.py new file mode 100644 index 0000000000000000000000000000000000000000..2432669eddf34ce2923f4affb937575990478989 --- /dev/null +++ b/AI-coach-agent/tests/test_swing_report_evidence_scope.py @@ -0,0 +1,42 @@ +"""A fluent sentence must not override measured scope, uncertainty or drill context.""" +from ai_coach.config import Settings +from ai_coach.swing_report.text import semantic_problems, write_texts + + +def facts(metric='hip_shoulder_separation_at_contact', *, supported=True): + return {'technique_correction_supported': supported, + 'groups': [{'group': 'contact_follow_through', 'metric_ids': [metric], 'rating': 'on_target'}], + 'measurements': [{'metric_id': metric, 'approximate': True, 'rating': 'on_target', + 'finding': 'Within the reference range.'}]} + + +def test_contact_angle_cannot_establish_follow_through_or_power(): + f = facts() + assert 'unmeasured_follow_through' in semantic_problems( + 'Your estimated follow-through is in the typical range.', 'group:contact_follow_through', f) + assert 'unsupported_physical_claim' in semantic_problems( + 'Your estimated turn creates more power.', 'group:contact_follow_through', f) + assert 'uncertainty_removed' in semantic_problems( + 'Your shoulder and hip gap is in the typical range.', 'group:contact_follow_through', f) + assert 'unsupported_shoulder_timing' in semantic_problems( + 'Your estimated shoulder turn started too early.', 'group:contact_follow_through', f) + + +def test_early_shoulder_turn_does_not_validate_entire_finish(): + f = facts('shoulder_rotation_after_contact') + assert 'follow_through_scope_exceeded' in semantic_problems( + 'Your estimated whole follow-through is in the typical range.', 'group:contact_follow_through', f) + assert not semantic_problems('Your estimated early shoulder turn is in the typical range.', + 'group:contact_follow_through', f) + + +def test_unknown_context_never_calls_model_for_free_form_technique_advice(): + def forbidden(*_): + raise AssertionError('No model advice is justified for an unknown drill.') + f = facts(supported=False) + rules = {'headline': 'These are estimated reference comparisons.', 'coach_message': 'Review the clip with your coach.'} + result = write_texts(f, rules, Settings(_env_file=None, google_api_key=None), generator=forbidden) + assert result.texts == rules and result.source == 'rules' + assert result.fallback_reason == 'insufficient_coaching_context' + assert 'unsupported_technique_correction' in semantic_problems( + 'Try a shorter step.', 'coach_message', f) diff --git a/AI-coach-agent/tests/test_swing_report_report.py b/AI-coach-agent/tests/test_swing_report_report.py index 9df663368b0807a4c79bb564d439ebc831e42207..7e3c4349173bcaa8291fbf3f21e2f597392b6f47 100644 --- a/AI-coach-agent/tests/test_swing_report_report.py +++ b/AI-coach-agent/tests/test_swing_report_report.py @@ -63,7 +63,7 @@ def test_spec_example(): sep = by_metric(r)["hip_shoulder_separation_at_foot_down"] assert (sep["score"], sep["rating"], sep["rating_label"], sep["display_value"]) == (55, "off_target", "Off Target", "3°") assert sep["benchmark"] == { - "benchmark_id": "obp-contract-v1.hip_shoulder_separation_at_foot_down.right.college", "version": "2026-10-21.1", + "benchmark_id": "obp-contract-v1.hip_shoulder_separation_at_foot_down.right.college", "version": "2026-10-31.1", "population": "College right-handed hitters (50 athletes)", "on_target": {"lower": -25.3, "upper": -8.5}, "satisfactory": {"lower": -32.5, "upper": -0.4}, "unit": "deg", "source_reference": "OpenBiomechanics Project hitting dataset (Driveline), percentiles P25-P75 and P10-P90"} @@ -89,12 +89,12 @@ def test_spec_example(): "how": "Set the tee on the outer half. Keep your front shoulder pointed at the pitcher until " "your hips have turned, then swing.", "cue": "Shoulder in.", "reps": "3x8"} assert focus["evidence_metric_ids"] == ["hip_shoulder_separation_at_foot_down"] - assert {n["code"] for n in r["data_quality"]} == {"contact_not_verified", "scale_is_model_estimated"} + assert {n["code"] for n in r["data_quality"]} == {"contact_not_verified", "scale_is_model_estimated", "partial_group_coverage"} meta = r["meta"] assert meta["text_source"] == "rules" and meta["model"] is None and meta["fallback_reason"] == "llm_not_configured" assert meta["request_id"] == "req_1" and meta["prompt_version"].startswith("swing-report-v1-") assert (meta["input_schema_version"], meta["measurement_definitions_version"], meta["benchmark_registry_version"], - meta["coaching_rules_version"]) == ("1.0", "1.0", "2026-10-21.1", "1.0") + meta["coaching_rules_version"]) == ("1.0", "1.0", "2026-10-31.1", "1.1") assert re.fullmatch(r"\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ", meta["generated_at"]) @@ -253,7 +253,7 @@ def test_level_mapping(level, cell, notes): r = build(athlete=AthleteContext(level=level)) assert by_metric(r)["hip_shoulder_separation_at_foot_down"]["benchmark"]["benchmark_id"].endswith(cell) codes = {n["code"] for n in r["data_quality"]} - {"contact_not_verified", "scale_is_model_estimated"} - assert codes == notes + assert codes == notes | {"partial_group_coverage"} def test_population_fallback_for_left_high_school(): @@ -319,13 +319,13 @@ def llm_settings(tmp_path, **kw) -> Settings: GOOD = { - "headline": "Your stride is the area to work on, because your shoulders turn open before your front foot lands.", - "group_summaries": [{"group": "stride", "summary": "Your step looks typical, but your shoulders open early."}], - "coach_message": "Your shoulders turn toward the pitcher too soon. Keep them closed so your hips can lead.", + "headline": "Your stride results are approximate. Your hip and shoulder angle differs from the reference.", + "group_summaries": [{"group": "stride", "summary": "Your step is an estimate, and your hip and shoulder angle differs from the reference."}], + "coach_message": "Your results are estimates. Let your hips lead as you turn.", "measurements": [ - {"metric_id": "hip_shoulder_separation_at_foot_down", "result_text": "Your shoulders opened before your foot landed.", + {"metric_id": "hip_shoulder_separation_at_foot_down", "result_text": "Your hip and shoulder angle differs from the reference.", "coach_tip": "Let your hips turn first."}, - {"metric_id": "stride_relative_length", "result_text": "Your step length is typical.", "coach_tip": ""}, + {"metric_id": "stride_relative_length", "result_text": "Your estimated step length is in the typical range.", "coach_tip": ""}, ], } @@ -424,4 +424,4 @@ def test_benchmarks_yaml_matches_generator(): def test_registry_drills_exist_and_catalog_lists(): assert {d["drill_id"] for d in repo.drills("hitting")} >= {"hit_01", "hit_13"} assert all(d["drill_id"].startswith("pit_") for d in repo.drills("pitching")) - assert repo.benchmark_version() == "2026-10-21.1" + assert repo.benchmark_version() == "2026-10-31.1" diff --git a/AI-coach-agent/tools/build_benchmarks.py b/AI-coach-agent/tools/build_benchmarks.py index 2095e553364e77a1734eaafd0124deb035b9e1f3..2355a7b0929e5c3d21c2b664bdaa96926e7f25d3 100644 --- a/AI-coach-agent/tools/build_benchmarks.py +++ b/AI-coach-agent/tools/build_benchmarks.py @@ -22,7 +22,7 @@ ROOT = Path(__file__).resolve().parents[1] DEFAULT_JSON = ROOT.parent / "data_ref" / "calibration" / "contract_v1" / "contract_v1_benchmarks.json" OUT = ROOT / "src" / "ai_coach" / "knowledge" / "benchmarks.yaml" -VERSION = "2026-10-21.1" +VERSION = "2026-10-31.1" MIN_ATHLETES = 5 HANDS = ("right", "left") OBP_LEVELS = ("high_school", "college", "pro") @@ -33,10 +33,15 @@ LEVEL_MAP = {"high_school": "high_school", "college": "college", "adult": "colle "unknown": "high_school"} FALLBACK_LEVEL = "college" UNITS = {"hip_shoulder_separation_at_foot_down": "deg", "hip_shoulder_separation_at_contact": "deg", - "stride_relative_length": "cm"} + "stride_relative_length": "cm", "torso_inclination_at_stride_start": "deg", + "hip_shoulder_separation_at_stride_start": "deg", "pelvis_rotation_to_contact": "deg", + "lead_knee_extension_to_contact": "deg", "torso_inclination_at_contact": "deg", + "shoulder_rotation_after_contact": "deg"} +EXTENDED_JSON = ROOT.parent / "data_ref" / "calibration" / "contract_v1_1" / "contract_v1_1_benchmarks.json" def build(data: dict) -> dict: + data = {**data, "metrics": {**data["metrics"], **json.loads(EXTENDED_JSON.read_text())["metrics"]}} metrics: dict = {} for metric_id, unit in UNITS.items(): cells = data["metrics"][metric_id] @@ -71,7 +76,7 @@ def build(data: dict) -> dict: HEADER = ( - "# GENERATED by tools/build_benchmarks.py from data_ref/calibration/contract_v1/contract_v1_benchmarks.json.\n" + "# GENERATED by tools/build_benchmarks.py from data_ref/calibration/contract_v1 and contract_v1_1.\n" "# Do not edit by hand: change the generator or the source data and regenerate.\n" ) diff --git a/backend/CONTRIBUTING.md b/backend/CONTRIBUTING.md index f382d73097e0da01302cc6be2a5d0fef781aa6d9..8f8abedb28458c971ab2c7fbd38fa4cf36d74600 100644 --- a/backend/CONTRIBUTING.md +++ b/backend/CONTRIBUTING.md @@ -22,15 +22,20 @@ These rules apply to every change in `backend/`. The design is in `DESIGN.md`. T |---|---| | CRUD | `app.common.base_repository.BaseRepository` (`get`, `get_or_404`, `first_by`, `list_by`, `exists_by`, `create`, `update`, `delete`) | | Errors | `app.core.errors`: `ValidationFailed` (400), `Unauthenticated` (401), `PlanLimitReached` (402), `Forbidden` (403), `NotFound` (404), `Conflict` (409, pass `code=`), `TooLarge` (413), `Unprocessable` (422), `RateLimited` (429), `ServiceUnavailable` (503). Pass `code=` for spec codes such as `EMAIL_TAKEN` and `fields=` for field errors. | -| Lists | `app.core.pagination` (`Paging` dependency, `encode_cursor`) and `common.schemas.Page[T]`, which returns `{items, next_cursor}` | +| Lists | `app.core.pagination` (`Paging` dependency, `paginate(rows_fetched_with_limit_plus_1, limit, key)` -> `(page, next_cursor)`, `encode_cursor`) and `common.schemas.Page[T]`, which returns `{items, next_cursor}` | | Plan and usage | `app.modules.billing.entitlement.EntitlementService(db)` (`get`, `ensure_can_analyze`) | -| Retried writes | `app.modules.idempotency.service.run_idempotent` (`Idempotency-Key` header) | +| Retried writes | `app.modules.idempotency.service.run_idempotent` (`Idempotency-Key` header; pass `scope=` when the route has a target id) | | Session list items | `app.modules.sessions.summary` (`summary_query`, `load_summaries`, `SessionSummary`) | | Team shape | `app.modules.teams.schemas.TeamOut` | | Review shape | `app.modules.reviews.schemas.ReviewOut` | -| Storage | `app.integrations.storage.StorageClient` (`presign_put`, `presign_get`, `head`, `delete_many`) | +| Storage | `app.integrations.storage.StorageClient` (`presign_put`, `presign_get`, `head`, `put_bytes`, `delete_many`) | +| Media URLs | `app.common.media` (`media_ref`, `upload_ref`) build every `MediaRef` | +| Claiming an upload | `app.common.uploads.claim_upload` (lock, owner, kind, already used, bytes present, set `attached_at`; each module passes its own `UploadErrors`) | +| Analysis consent | `app.common.consent.analysis_consent_blocked(db, account_id, require_accepted)` | +| Labels and tones | `app.common.labels` (`DISCIPLINES`, `FOCUS_LABEL`, `tone`, `tone_counts`, `drill_catalog`) | +| Account names | `app.common.names.account_names(session, ids)` | | Tokens and passwords | `app.core.security` | -| Rate limits | `app.core.rate_limit` (`RateLimiter`; tests reset all limiters automatically) | +| Rate limits | `app.core.rate_limit` (`RateLimiter` and one named getter per limiter, e.g. `get_academy_apply_limiter`; tests reset all limiters automatically) | **Do not edit these shared files.** If one needs a change, describe it in your report instead: - `app/core/*` diff --git a/backend/app/common/consent.py b/backend/app/common/consent.py new file mode 100644 index 0000000000000000000000000000000000000000..d3eacf8c2c8af0bc9286b973da74fb1483090199 --- /dev/null +++ b/backend/app/common/consent.py @@ -0,0 +1,17 @@ +"""Whether the player's analysis consent allows running an analysis.""" + +from uuid import UUID + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.modules.settings.models import ConsentEvent + + +async def analysis_consent_blocked(db: AsyncSession, account_id: UUID, require_accepted: bool) -> bool: + """True when the latest analysis consent is a withdrawal, or (when required) there is no acceptance.""" + action = await db.scalar( + select(ConsentEvent.action) + .where(ConsentEvent.account_id == account_id, ConsentEvent.category == "analysis") + .order_by(ConsentEvent.created_at.desc(), ConsentEvent.id.desc()).limit(1)) + return action == "withdrawn" or (require_accepted and action is None) diff --git a/backend/app/common/labels.py b/backend/app/common/labels.py new file mode 100644 index 0000000000000000000000000000000000000000..354b187fe9246af9038ddd06083e8ae7267e81ab --- /dev/null +++ b/backend/app/common/labels.py @@ -0,0 +1,30 @@ +"""Small lookups shared by several modules: mode and focus labels, score tones, the drill catalog.""" + +from collections.abc import Iterable +from functools import cache + +DISCIPLINES = {"h": "hitting", "p": "pitching"} # session mode -> ai_coach drill discipline +FOCUS_LABEL = {"h": "Hitting", "p": "Pitching", "both": "Both"} # coach focus -> display label +TONE_GREEN_MIN = 80 # overall score at or above: "g"; at or above TONE_YELLOW_MIN: "y"; below: "r" +TONE_YELLOW_MIN = 60 + + +@cache +def drill_catalog() -> dict[str, dict]: + """ai_coach catalog drills by id.""" + from ai_coach.knowledge import all_drills + + return {d["id"]: d for d in all_drills()} + + +def tone(score: int | None) -> str: + if score is None: + return "y" + return "g" if score >= TONE_GREEN_MIN else "y" if score >= TONE_YELLOW_MIN else "r" + + +def tone_counts(scores: Iterable[int]) -> dict[str, int]: + counts = dict.fromkeys("gyr", 0) + for score in scores: + counts[tone(score)] += 1 + return counts diff --git a/backend/app/common/media.py b/backend/app/common/media.py new file mode 100644 index 0000000000000000000000000000000000000000..984b87676a3ef7b11a6d1494da6ac715ab14eff9 --- /dev/null +++ b/backend/app/common/media.py @@ -0,0 +1,17 @@ +"""Short-lived read URLs for stored media. Every module that returns a MediaRef builds it here.""" + +from datetime import UTC, datetime, timedelta +from uuid import UUID + +from app.common.schemas import MediaRef +from app.integrations.storage import StorageClient +from app.modules.uploads.models import Upload + + +def media_ref(storage: StorageClient, upload_id: UUID, object_key: str, seconds: float | None = None) -> MediaRef: + return MediaRef(upload_id=upload_id, url=storage.presign_get(object_key), + expires_at=datetime.now(UTC) + timedelta(seconds=storage.download_ttl), seconds=seconds) + + +def upload_ref(storage: StorageClient, upload: Upload | None, seconds: float | None = None) -> MediaRef | None: + return media_ref(storage, upload.id, upload.object_key, seconds) if upload is not None else None diff --git a/backend/app/common/names.py b/backend/app/common/names.py new file mode 100644 index 0000000000000000000000000000000000000000..c254a080852af0ecebf78fa1f80ed8ce1f256280 --- /dev/null +++ b/backend/app/common/names.py @@ -0,0 +1,17 @@ +"""Display names for a set of accounts in one query.""" + +from collections.abc import Iterable +from uuid import UUID + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.modules.accounts.models import Account + + +async def account_names(session: AsyncSession, ids: Iterable[UUID | None]) -> dict[UUID, str | None]: + wanted = {i for i in ids if i} + if not wanted: + return {} + rows = await session.execute(select(Account.id, Account.name).where(Account.id.in_(wanted))) + return {i: n for i, n in rows} diff --git a/backend/app/common/uploads.py b/backend/app/common/uploads.py new file mode 100644 index 0000000000000000000000000000000000000000..49d60548934e65b0b354e3608e40db1b1a84a24c --- /dev/null +++ b/backend/app/common/uploads.py @@ -0,0 +1,43 @@ +"""Claiming an upload for a record: ownership, kind, not already used, bytes present, then mark it attached.""" + +from collections.abc import Awaitable, Callable +from dataclasses import dataclass +from datetime import UTC, datetime +from uuid import UUID + +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession + +from app.integrations.storage import StorageClient +from app.modules.uploads.models import Upload + + +@dataclass(frozen=True) +class UploadErrors: + """The exceptions each module raises for a failed claim (they differ in code and wording).""" + + invalid: Exception # missing or not the caller's + used: Exception + not_ready: Exception + wrong_kind: Exception | None = None # defaults to invalid + + +async def claim_upload( + db: AsyncSession, storage: StorageClient, upload_id: UUID, *, owner_id: UUID, kind: str, errors: UploadErrors, + in_use: Callable[[], Awaitable[bool]] | None = None, + reusable: Callable[[], Awaitable[bool]] | None = None, +) -> None: + """Lock the upload row so concurrent claims serialize. in_use also counts rows that reference it without + attached_at set; reusable says a claim on an already attached upload is the same record re-sending it.""" + upload = await db.scalar(select(Upload).where(Upload.id == upload_id).with_for_update()) + if upload is None or upload.owner_id != owner_id: + raise errors.invalid + if upload.kind != kind: + raise errors.wrong_kind or errors.invalid + attached = upload.attached_at is not None + if attached and not (reusable and await reusable()) or (not attached and in_use and await in_use()): + raise errors.used + if await storage.head(upload.object_key) is None: + raise errors.not_ready + if not attached: + upload.attached_at = datetime.now(UTC) diff --git a/backend/app/core/pagination.py b/backend/app/core/pagination.py index 3aa084c81e5a07058d0e452feaf1f508ff5116dc..2dc72797f945ad71956df90344b2ee1f7cae9ff9 100644 --- a/backend/app/core/pagination.py +++ b/backend/app/core/pagination.py @@ -2,8 +2,10 @@ import base64 import json +from collections.abc import Callable, Sequence from dataclasses import dataclass from datetime import datetime +from typing import TypeVar from uuid import UUID from fastapi import Query @@ -31,6 +33,18 @@ def decode_cursor(value: str) -> Cursor: raise ValidationFailed(fields={"cursor": "Invalid cursor."}) from exc +T = TypeVar("T") + + +def paginate(rows: Sequence[T], limit: int, key: Callable[[T], tuple[datetime, UUID]] | None = None + ) -> tuple[list[T], str | None]: + """Split rows fetched with limit + 1 into the page and its next cursor. key gives (created_at, id).""" + page = list(rows[:limit]) + if len(rows) <= limit: + return page, None + return page, encode_cursor(*(key(page[-1]) if key else (page[-1].created_at, page[-1].id))) # type: ignore[attr-defined] + + @dataclass(frozen=True) class PageParams: limit: int diff --git a/backend/app/core/rate_limit.py b/backend/app/core/rate_limit.py index 1ed8a092f34b486368e5ae71256bdeb1b827ac18..df7bc8edde1fca2774fcf24a6d1e22460c0066d8 100644 --- a/backend/app/core/rate_limit.py +++ b/backend/app/core/rate_limit.py @@ -67,3 +67,8 @@ def get_rate_limiter() -> RateLimiter: @lru_cache def get_team_lookup_limiter() -> RateLimiter: return RateLimiter(30) + + +@lru_cache +def get_academy_apply_limiter() -> RateLimiter: + return RateLimiter(10) diff --git a/backend/app/integrations/storage.py b/backend/app/integrations/storage.py index d4b3c5e673a86bd966039769dc90252353f92595..70b53911574beec43812076192fb1824cb89a4fd 100644 --- a/backend/app/integrations/storage.py +++ b/backend/app/integrations/storage.py @@ -49,6 +49,9 @@ class StorageClient: raise return ObjectInfo(size_bytes=int(meta["ContentLength"]), content_type=meta.get("ContentType", "")) + async def put_bytes(self, key: str, data: bytes, content_type: str) -> None: + await asyncio.to_thread(self._s3.put_object, Bucket=self.bucket, Key=key, Body=data, ContentType=content_type) + async def read_prefix(self, key: str, length: int) -> bytes: response = await asyncio.to_thread( self._s3.get_object, Bucket=self.bucket, Key=key, Range=f"bytes=0-{length - 1}") diff --git a/backend/app/modules/academy_org/repository.py b/backend/app/modules/academy_org/repository.py index e818ecfa7bd703b3cb31ed39e371bfd5d0a6186b..da0dcd2f5f7bcb86e5d37830f0c056bb7ec8b3f3 100644 --- a/backend/app/modules/academy_org/repository.py +++ b/backend/app/modules/academy_org/repository.py @@ -1,7 +1,6 @@ """Groups, private coach notes, roster additions and the academy library. Database only.""" from collections.abc import Sequence -from datetime import datetime from uuid import UUID from sqlalchemy import Select, and_, or_, select @@ -168,10 +167,3 @@ class OrgRepository(BaseRepository[PlayerGroup]): .outerjoin(Account, Account.id == LibraryDrill.author_id) .outerjoin(Upload, Upload.id == LibraryDrill.upload_id)) - async def upload(self, upload_id: UUID, owner_id: UUID) -> Upload | None: - return await self.session.scalar(select(Upload).where(Upload.id == upload_id, Upload.owner_id == owner_id) - .with_for_update()) - - async def attach(self, upload: Upload, when: datetime) -> None: - upload.attached_at = when - await self.session.flush() diff --git a/backend/app/modules/academy_org/service.py b/backend/app/modules/academy_org/service.py index 76fcace4eff631962c57488184935277156bc478..a0ba452fe44e568eb580b0be4ab52040a0c8afa2 100644 --- a/backend/app/modules/academy_org/service.py +++ b/backend/app/modules/academy_org/service.py @@ -1,14 +1,16 @@ """Academy groups (N28-N29), private coach notes (N30-N31), roster additions (N32-N33) and the library (N35-N36).""" -from datetime import UTC, datetime, timedelta +from datetime import UTC, datetime from uuid import UUID from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import Staff, require_player, visible_player_ids -from app.common.schemas import MediaRef, Page +from app.common.media import media_ref +from app.common.schemas import Page +from app.common.uploads import UploadErrors, claim_upload from app.core.errors import Conflict, NotFound, Unprocessable -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.integrations.storage import StorageClient from app.modules.academy.models import LibraryDrill, PlayerGroup from app.modules.academy_org.repository import OrgRepository @@ -29,15 +31,6 @@ def _dedupe(ids: list[UUID]) -> list[UUID]: return list(dict.fromkeys(ids)) -def _page(items: list, limit: int, created_at) -> Page: - """items holds up to limit+1 rows; created_at(item) gives (created_at, id) for the cursor.""" - next_cursor = None - if len(items) > limit: - items = items[:limit] - next_cursor = encode_cursor(*created_at(items[-1])) - return Page(items=items, next_cursor=next_cursor) - - class OrgService: def __init__(self, db: AsyncSession, storage: StorageClient): self.db = db @@ -67,7 +60,8 @@ class OrgService: visible = None if staff.sees_all else set(await visible_player_ids(self.db, staff)) outs = await self._group_outs(rows, visible) by_id = {g.id: g for g in rows} - return _page(outs, paging.limit, lambda o: (by_id[o.id].created_at, o.id)) + items, next_cursor = paginate(outs, paging.limit, lambda o: (by_id[o.id].created_at, o.id)) + return Page[GroupOut](items=items, next_cursor=next_cursor) async def create_group(self, staff: Staff, body: GroupIn) -> GroupOut: team_id = staff.team_id @@ -124,7 +118,8 @@ class OrgService: created = {r.id: r.created_at for r in rows} items = [MemberOut(id=r.id, name=r.name or "", focus=r.focus, level=r.level, group_ids=groups.get(r.id, [])) for r in rows] - return _page(items, paging.limit, lambda m: (created[m.id], m.id)) + items, next_cursor = paginate(items, paging.limit, lambda m: (created[m.id], m.id)) + return Page[MemberOut](items=items, next_cursor=next_cursor) async def add_to_roster(self, staff: Staff, body: RosterAddIn) -> RosterAddOut: player_ids = _dedupe(body.player_ids) @@ -146,8 +141,7 @@ class OrgService: drill, author, key = row media = None if drill.upload_id is not None and key is not None: - expires = datetime.now(UTC) + timedelta(seconds=self.storage.download_ttl) - media = MediaRef(upload_id=drill.upload_id, url=self.storage.presign_get(key), expires_at=expires) + media = media_ref(self.storage, drill.upload_id, key) return LibraryDrillOut(id=drill.id, name=drill.name, fixes=drill.fixes, fault_tags=list(drill.fault_tags), by=author, author_id=drill.author_id, mode=drill.mode, media=media, created_at=drill.created_at) @@ -157,22 +151,20 @@ class OrgService: if staff.team_id is None: return Page[LibraryDrillOut](items=[]) rows = await self.repo.library(staff.team_id, mode, fault_tag, paging.cursor, paging.limit + 1) - return _page([self._drill_out(r) for r in rows], paging.limit, lambda d: (d.created_at, d.id)) + items, next_cursor = paginate([self._drill_out(r) for r in rows], paging.limit) + return Page[LibraryDrillOut](items=items, next_cursor=next_cursor) async def publish_drill(self, staff: Staff, body: LibraryDrillIn) -> LibraryDrillOut: staff.require("library") - upload = await self.repo.upload(body.upload_id, staff.id) - if upload is None: - raise NotFound("Upload not found.") - if upload.kind != "drill_video": - raise Unprocessable("This upload is not a drill video.", code="INVALID_MEDIA") - if upload.attached_at is not None: - raise Conflict("This video is already in use.", code="UPLOAD_ALREADY_USED") - if await self.storage.head(upload.object_key) is None: - raise Conflict("The video has not finished uploading.", code="UPLOAD_NOT_READY") + await claim_upload( + self.db, self.storage, body.upload_id, owner_id=staff.id, kind="drill_video", + errors=UploadErrors( + invalid=NotFound("Upload not found."), + used=Conflict("This video is already in use.", code="UPLOAD_ALREADY_USED"), + not_ready=Conflict("The video has not finished uploading.", code="UPLOAD_NOT_READY"), + wrong_kind=Unprocessable("This upload is not a drill video.", code="INVALID_MEDIA"))) drill = LibraryDrill(team_id=staff.team_id, author_id=staff.id, name=body.name, fixes=body.fixes, - mode=body.mode, fault_tags=body.fault_tags, upload_id=upload.id) + mode=body.mode, fault_tags=body.fault_tags, upload_id=body.upload_id) self.db.add(drill) await self.db.flush() - await self.repo.attach(upload, datetime.now(UTC)) return self._drill_out(await self.repo.library_row(drill.id)) diff --git a/backend/app/modules/academy_staff/controller.py b/backend/app/modules/academy_staff/controller.py index ba7d7cc702d66c2fae0b046117fd520bbdb32b5a..7dd59e9505a2868a331ae168efd82f3d82134e3d 100644 --- a/backend/app/modules/academy_staff/controller.py +++ b/backend/app/modules/academy_staff/controller.py @@ -6,7 +6,6 @@ from uuid import UUID from fastapi import APIRouter, Header, Query, Response from fastapi.responses import JSONResponse -from pydantic import BaseModel from app.common.academy_access import CurrentAdmin, CurrentStaff, staff_context from app.common.schemas import Page @@ -32,13 +31,6 @@ router = APIRouter(prefix="/v1", tags=["academy_staff"]) IdempotencyKey = Annotated[str | None, Header(max_length=128)] -class _Scoped(BaseModel): - """Idempotency payload that also covers the path id, so one key cannot replay across targets.""" - - target: UUID - body: dict - - @router.get("/me/coach-access", response_model=CoachAccessBody) async def get_coach_access(db: Db, account: CurrentAccount) -> CoachAccessBody: return CoachAccessBody(coach_access=await StaffService(db).coach_access(account, await staff_context(db, account))) @@ -92,9 +84,9 @@ async def list_requests(db: Db, staff: CurrentAdmin, paging: Paging, @router.post("/academy/coach-requests/{request_id}/decision", response_model=DecisionOut) async def decide_request(request_id: UUID, body: DecisionIn, db: Db, staff: CurrentAdmin, idempotency_key: IdempotencyKey = None) -> JSONResponse: - scoped = _Scoped(target=request_id, body=body.model_dump(mode="json")) - return await run_idempotent(db, staff.id, idempotency_key, scoped, - lambda: StaffService(db).decide(staff, request_id, body), status_code=200) + return await run_idempotent(db, staff.id, idempotency_key, body, + lambda: StaffService(db).decide(staff, request_id, body), status_code=200, + scope=request_id) @router.get("/academy/staff-codes", response_model=Page[StaffCodeOut]) diff --git a/backend/app/modules/academy_staff/repository.py b/backend/app/modules/academy_staff/repository.py index db1aad53295d366b8fbd0253350e0eb852c89b22..801c934d29f575f60c1fb7de50367f8dd8f03c14 100644 --- a/backend/app/modules/academy_staff/repository.py +++ b/backend/app/modules/academy_staff/repository.py @@ -55,10 +55,17 @@ class StaffRepository(BaseRepository[AcademyMembership]): # ----- groups ----- async def group_ids(self, team_id: UUID, coach_id: UUID) -> list[UUID]: - return list((await self.session.scalars( - select(GroupCoach.group_id).join(PlayerGroup, PlayerGroup.id == GroupCoach.group_id) - .where(PlayerGroup.team_id == team_id, GroupCoach.coach_id == coach_id) - .order_by(PlayerGroup.created_at, PlayerGroup.id))).all()) + return (await self.group_ids_many(team_id, [coach_id])).get(coach_id, []) + + async def group_ids_many(self, team_id: UUID, coach_ids: list[UUID]) -> dict[UUID, list[UUID]]: + rows = await self.session.execute( + select(GroupCoach.coach_id, GroupCoach.group_id).join(PlayerGroup, PlayerGroup.id == GroupCoach.group_id) + .where(PlayerGroup.team_id == team_id, GroupCoach.coach_id.in_(coach_ids)) + .order_by(PlayerGroup.created_at, PlayerGroup.id)) + grouped: dict[UUID, list[UUID]] = {} + for coach_id, group_id in rows: + grouped.setdefault(coach_id, []).append(group_id) + return grouped async def count_groups(self, team_id: UUID, group_ids: list[UUID]) -> int: return await self.session.scalar(select(func.count()).select_from(PlayerGroup).where( @@ -88,21 +95,26 @@ class StaffRepository(BaseRepository[AcademyMembership]): await self.add_groups(to_id, old) # ----- activity ----- - async def review_activity(self, team_id: UUID, coach_id: UUID, start: datetime, end: datetime): - """(reviews, avg hours from session creation to the review) for reviews written in [start, end).""" + async def review_activity(self, team_id: UUID, coach_ids: list[UUID], start: datetime, end: datetime + ) -> dict[UUID, tuple[int, float | None]]: + """coach id -> (reviews, avg hours from session creation to the review) for reviews written in [start, end).""" seconds = func.extract("epoch", Review.updated_at - SwingSession.created_at) - row = (await self.session.execute( - select(func.count(), func.avg(seconds) / 3600) + rows = await self.session.execute( + select(Review.coach_id, func.count(), func.avg(seconds) / 3600) .select_from(Review).join(SwingSession, SwingSession.id == Review.session_id) .join(Account, Account.id == SwingSession.owner_id) - .where(Account.team_id == team_id, Review.coach_id == coach_id, SwingSession.deleted_at.is_(None), - Review.updated_at >= start, Review.updated_at < end))).one() - return row[0], (round(float(row[1]), 1) if row[1] is not None else None) - - async def drills_set(self, team_id: UUID, coach_id: UUID, start: datetime, end: datetime) -> int: - return await self.session.scalar(select(func.count()).select_from(DrillAssignment).where( - DrillAssignment.team_id == team_id, DrillAssignment.assigned_by_id == coach_id, - DrillAssignment.created_at >= start, DrillAssignment.created_at < end)) or 0 + .where(Account.team_id == team_id, Review.coach_id.in_(coach_ids), SwingSession.deleted_at.is_(None), + Review.updated_at >= start, Review.updated_at < end).group_by(Review.coach_id)) + return {c: (n, round(float(avg), 1) if avg is not None else None) for c, n, avg in rows} + + async def drills_set(self, team_id: UUID, coach_ids: list[UUID], start: datetime, end: datetime + ) -> dict[UUID, int]: + rows = await self.session.execute( + select(DrillAssignment.assigned_by_id, func.count()).where( + DrillAssignment.team_id == team_id, DrillAssignment.assigned_by_id.in_(coach_ids), + DrillAssignment.created_at >= start, DrillAssignment.created_at < end) + .group_by(DrillAssignment.assigned_by_id)) + return dict(rows.all()) async def count(self, query) -> int: return await self.session.scalar(select(func.count()).select_from(query.subquery())) or 0 diff --git a/backend/app/modules/academy_staff/service.py b/backend/app/modules/academy_staff/service.py index 11ceba26c0705826c3c8efef0d0a01c103a63ca4..4983185458f1eee26cacb54a44d58cdacab6aa81 100644 --- a/backend/app/modules/academy_staff/service.py +++ b/backend/app/modules/academy_staff/service.py @@ -9,9 +9,10 @@ from uuid import UUID from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import Staff, normalize_permissions, visible_players_query +from app.common.labels import FOCUS_LABEL from app.core.errors import Conflict, Forbidden, NotFound, Unprocessable -from app.core.pagination import PageParams, encode_cursor -from app.core.rate_limit import RateLimiter +from app.core.pagination import PageParams, paginate +from app.core.rate_limit import get_academy_apply_limiter from app.modules.academy.models import AcademyMembership, CoachAccessRequest, StaffCode from app.modules.academy_staff.repository import StaffRepository from app.modules.academy_staff.schemas import ( @@ -30,8 +31,6 @@ from app.modules.accounts.models import Account from app.modules.teams.models import Team CODE_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZ23456789" # no 0/O/1/I/L -COACHES_LABEL = {"h": "Hitting", "p": "Pitching", "both": "Both"} -_apply_limiter = RateLimiter(10, 60.0) def normalize_code(code: str) -> str: @@ -91,7 +90,7 @@ class StaffService: async def apply(self, account: Account, raw_code: str) -> tuple[CoachAccessOut, bool]: """Returns (coach_access, created). Uses are counted at submission and a decline does not give one back.""" - _apply_limiter.hit(f"coach_apply:{account.id}") + get_academy_apply_limiter().hit(f"coach_apply:{account.id}") code = normalize_code(raw_code) row = await self.repo.code_row(code, lock=True) if row is None: @@ -155,20 +154,30 @@ class StaffService: return start, end async def _out(self, team: Team, member: Member, me_id: UUID, start: date, end: date) -> CoachOut: + return (await self._outs(team, [member], me_id, start, end))[0] + + async def _outs(self, team: Team, members: list[Member], me_id: UUID, start: date, end: date) -> list[CoachOut]: + """Activity and group queries run once for all members; only the visible-player count is per member.""" lo = datetime.combine(start, time.min, UTC) hi = datetime.combine(end + timedelta(days=1), time.min, UTC) - who = Staff(member.account, team.id, member.role, member.sees_all, member.permissions) - reviews, avg_hours = await self.repo.review_activity(team.id, member.account.id, lo, hi) - activity = ActivityOut( - reviews=reviews, avg_reply_hours=avg_hours, players=await self.repo.count(visible_players_query(who)), - drills_set=await self.repo.drills_set(team.id, member.account.id, lo, hi), - period_start=start, period_end=end) - return CoachOut( - id=member.account.id, name=member.account.name, coaches=COACHES_LABEL[member.account.focus], - joined=member.joined, joined_with=member.joined_with, role=member.role, - is_me=member.account.id == me_id, sees_all=member.sees_all, - group_ids=await self.repo.group_ids(team.id, member.account.id), permissions=member.permissions, - activity=activity, status=member.status, version=member.version) + ids = [m.account.id for m in members] + reviews = await self.repo.review_activity(team.id, ids, lo, hi) + drills = await self.repo.drills_set(team.id, ids, lo, hi) + groups = await self.repo.group_ids_many(team.id, ids) + out = [] + for member in members: + who = Staff(member.account, team.id, member.role, member.sees_all, member.permissions) + count, avg_hours = reviews.get(member.account.id, (0, None)) + activity = ActivityOut( + reviews=count, avg_reply_hours=avg_hours, players=await self.repo.count(visible_players_query(who)), + drills_set=drills.get(member.account.id, 0), period_start=start, period_end=end) + out.append(CoachOut( + id=member.account.id, name=member.account.name, coaches=FOCUS_LABEL[member.account.focus], + joined=member.joined, joined_with=member.joined_with, role=member.role, + is_me=member.account.id == me_id, sees_all=member.sees_all, + group_ids=groups.get(member.account.id, []), permissions=member.permissions, + activity=activity, status=member.status, version=member.version)) + return out async def list_coaches(self, staff: Staff, status: str | None) -> list[CoachOut]: team = await self._team(staff) @@ -179,7 +188,7 @@ class StaffService: owner = await self.repo.account(team.coach_id) members.insert(0, self._owner(team, owner)) # type: ignore[arg-type] start, end = self._period(None, None) - items = [await self._out(team, m, staff.id, start, end) for m in members] + items = await self._outs(team, members, staff.id, start, end) if staff.role != "admin": # colleagues' staff code, permissions and activity are admin-only items = [c.model_copy(update={"joined_with": None, "permissions": None, "activity": None}) if not c.is_me else c for c in items] @@ -257,8 +266,7 @@ class StaffService: async def list_requests(self, staff: Staff, status: str, paging: PageParams) -> RequestPage: rows = await self.repo.requests(staff.team_id, status, paging.limit, paging.cursor) # type: ignore[arg-type] - page = rows[:paging.limit] - next_cursor = encode_cursor(page[-1][0].created_at, page[-1][0].id) if len(rows) > paging.limit else None + page, next_cursor = paginate(rows, paging.limit, lambda r: (r[0].created_at, r[0].id)) return RequestPage(items=[self._request_out(r, a) for r, a in page], next_cursor=next_cursor, total_pending=await self.repo.total_pending(staff.team_id)) # type: ignore[arg-type] @@ -316,8 +324,7 @@ class StaffService: async def list_codes(self, staff: Staff, status: str, paging: PageParams): now = _now() rows = await self.repo.codes(staff.team_id, status, now, paging.limit, paging.cursor) # type: ignore[arg-type] - page = rows[:paging.limit] - next_cursor = encode_cursor(page[-1].created_at, page[-1].id) if len(rows) > paging.limit else None + page, next_cursor = paginate(rows, paging.limit) return [code_out(c, now) for c in page], next_cursor async def create_code(self, staff: Staff, body: StaffCodeCreate) -> StaffCodeOut: diff --git a/backend/app/modules/api_audit/service.py b/backend/app/modules/api_audit/service.py index 2668deeb03e4c0cfdc3ad0c7e1660e1c4f1ebbf9..c05de0960954630a3fd6d416310202415d7fdecc 100644 --- a/backend/app/modules/api_audit/service.py +++ b/backend/app/modules/api_audit/service.py @@ -7,7 +7,7 @@ from app.common.schemas import Page from app.core.config import get_settings from app.core.database import get_session_factory from app.core.errors import ValidationFailed -from app.core.pagination import encode_cursor +from app.core.pagination import paginate from app.modules.api_audit.models import ApiRequestLog from app.modules.api_audit.repository import AuditLogRepository from app.modules.api_audit.schemas import AuditLogDetail, AuditLogSummary @@ -38,10 +38,9 @@ class AuditLogService: if paging.cursor and paging.cursor.created_at.utcoffset() is None: raise ValidationFailed(fields={"cursor": "Cursor timestamp needs a timezone."}) rows = await self.repo.search(paging, filters, since, until) - more = len(rows) > paging.limit - rows = rows[:paging.limit] + rows, next_cursor = paginate(rows, paging.limit) return Page[AuditLogSummary](items=[AuditLogSummary.model_validate(row) for row in rows], - next_cursor=encode_cursor(rows[-1].created_at, rows[-1].id) if more else None) + next_cursor=next_cursor) async def get(self, log_id): return AuditLogDetail.model_validate(await self.repo.get_or_404(log_id)) diff --git a/backend/app/modules/assignments/controller.py b/backend/app/modules/assignments/controller.py index 5591ee7fe527ddc6eed1796fe070b3906f72a729..b7968251960dd725074d8204af86942b6a773215 100644 --- a/backend/app/modules/assignments/controller.py +++ b/backend/app/modules/assignments/controller.py @@ -4,7 +4,6 @@ from typing import Annotated, Literal from uuid import UUID from fastapi import APIRouter, Depends, Header, Query -from pydantic import BaseModel from app.common.academy_access import CurrentStaff from app.core.dependencies import CurrentAccount, CurrentPlayer, Db, Paging, Storage @@ -16,13 +15,6 @@ from app.modules.idempotency.service import run_idempotent router = APIRouter(prefix="/v1", tags=["assignments"]) -class _Scoped(BaseModel): - """Idempotency payload that also covers the path id, so one key cannot replay across targets.""" - - target: UUID - body: dict - - @router.get("/drill-assignments", response_model=AssignmentPage) async def list_assignments( mode: Annotated[Mode, Query()], account: CurrentAccount, db: Db, storage: Storage, paging: Paging, @@ -42,8 +34,7 @@ async def assign_drill( async def handler() -> AssignmentEnvelope: return AssignmentEnvelope(assignment=await service.assign(staff, player_id, body)) - scoped = _Scoped(target=player_id, body=body.model_dump(mode="json")) - return await run_idempotent(db, staff.id, idempotency_key, scoped, handler, status_code=201) + return await run_idempotent(db, staff.id, idempotency_key, body, handler, status_code=201, scope=player_id) @router.post("/drill-assignments/{assignment_id}/sets", status_code=201, response_model=SetResult) @@ -56,6 +47,5 @@ async def log_set( async def handler() -> SetResult: return await service.log_set(player, assignment_id, body) - return await run_idempotent(db, player.id, idempotency_key, - _Scoped(target=assignment_id, body=body.model_dump(mode="json")), handler, - status_code=201) + return await run_idempotent(db, player.id, idempotency_key, body, handler, status_code=201, + scope=assignment_id) diff --git a/backend/app/modules/assignments/repository.py b/backend/app/modules/assignments/repository.py index f99b368722a721477c62edf232cdbfc7c02a983d..a471165e7e36ab1402c8df81e07db650d512dd25 100644 --- a/backend/app/modules/assignments/repository.py +++ b/backend/app/modules/assignments/repository.py @@ -4,9 +4,9 @@ from uuid import UUID from sqlalchemy import Select, exists, func, select, tuple_ from app.common.base_repository import BaseRepository +from app.common.names import account_names from app.core.pagination import Cursor from app.modules.academy.models import LibraryDrill -from app.modules.accounts.models import Account from app.modules.assignments.models import AssignmentSet, DrillAssignment from app.modules.drills.models import DrillLog from app.modules.sessions.models import SwingSession @@ -33,11 +33,7 @@ class AssignmentRepository(BaseRepository[DrillAssignment]): select(func.count()).select_from(AssignmentSet).where(AssignmentSet.assignment_id == assignment_id)) or 0 async def names(self, ids: set[UUID | None]) -> dict[UUID, str]: - ids = {i for i in ids if i} - if not ids: - return {} - rows = await self.session.execute(select(Account.id, Account.name).where(Account.id.in_(ids))) - return {i: n for i, n in rows} + return await account_names(self.session, ids) def list_query(self, *, mode: str, status: str, player_ids: Select | None, player_id: UUID | None, team_id: UUID | None) -> Select: diff --git a/backend/app/modules/assignments/service.py b/backend/app/modules/assignments/service.py index 1c8ec4b9ccb96cea99fc07845c074320ffbc16ed..9bc92df91b46f18a2921da1a56219e651963558b 100644 --- a/backend/app/modules/assignments/service.py +++ b/backend/app/modules/assignments/service.py @@ -1,10 +1,8 @@ """Drill assignments (N20-N22). Progress is the number of AssignmentSet rows; each set also writes one drill log.""" -from datetime import UTC, date, datetime, timedelta -from functools import cache +from datetime import UTC, date, datetime from uuid import UUID -from ai_coach.knowledge import all_drills from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import ( @@ -14,10 +12,11 @@ from app.common.academy_access import ( staff_context, visible_players_query, ) +from app.common.labels import DISCIPLINES, drill_catalog +from app.common.media import media_ref from app.common.notify import notify -from app.common.schemas import MediaRef from app.core.errors import Conflict, Forbidden, NotFound, Unprocessable, ValidationFailed -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.integrations.push import PushClient from app.integrations.storage import StorageClient from app.modules.accounts.models import Account @@ -25,13 +24,6 @@ from app.modules.assignments.models import DrillAssignment from app.modules.assignments.repository import AssignmentRepository from app.modules.assignments.schemas import AssignIn, AssignmentOut, AssignmentPage, SetIn, SetLogOut, SetResult -DISCIPLINES = {"h": "hitting", "p": "pitching"} - - -@cache -def _catalog() -> dict[str, dict]: - return {d["id"]: d for d in all_drills()} - def due_label(due: date, today: date) -> str: days = (due - today).days @@ -61,8 +53,7 @@ class AssignmentService: ref = None if a.drill_source == "library" and self.storage is not None and UUID(a.drill_id) in media: upload_id, key = media[UUID(a.drill_id)] - ref = MediaRef(upload_id=upload_id, url=self.storage.presign_get(key), - expires_at=datetime.now(UTC) + timedelta(seconds=self.storage.download_ttl)) + ref = media_ref(self.storage, upload_id, key) out.append(AssignmentOut( id=a.id, player_id=a.player_id, mode=a.mode, drill_id=a.drill_id, drill_source=a.drill_source, name=a.name, fixes=a.fixes, sets=a.sets, reps=a.reps, due=due_label(a.due_date, today), @@ -90,15 +81,14 @@ class AssignmentService: query = self.repo.list_query(mode=mode, status=status, player_ids=visible_players_query(staff), player_id=player_id, team_id=staff.team_id) rows = await self.repo.page(query, paging.cursor, paging.limit) - page = rows[:paging.limit] + page, cursor = paginate(rows, paging.limit, lambda r: (r[0].created_at, r[0].id)) items = await self._outs([(a, n) for a, n in page]) - cursor = encode_cursor(page[-1][0].created_at, page[-1][0].id) if len(rows) > paging.limit else None return AssignmentPage(items=items, next_cursor=cursor) async def _source(self, staff: Staff, body: AssignIn) -> tuple[str, str]: """(name, fixes) snapshot of the drill, or the error to raise.""" if body.drill_source == "catalog": - drill = _catalog().get(body.drill_id) + drill = drill_catalog().get(body.drill_id) if drill is None: raise NotFound("Drill not found.", code="DRILL_NOT_FOUND") if drill["discipline"] != DISCIPLINES[body.mode]: diff --git a/backend/app/modules/catalog/service.py b/backend/app/modules/catalog/service.py index 04a933bad459f0be99fbddc5b285a1cf6f49dd7d..6f25f05ce1f878575bd841a6e5a63ffb55fc0e99 100644 --- a/backend/app/modules/catalog/service.py +++ b/backend/app/modules/catalog/service.py @@ -2,10 +2,9 @@ from ai_coach.swing_report import repository as registry +from app.common.labels import DISCIPLINES from app.modules.catalog.schemas import CatalogOut, DrillOut, GroupOut, MetricOut -DISCIPLINES = {"h": "hitting", "p": "pitching"} - class CatalogService: def metrics(self, mode: str) -> CatalogOut: diff --git a/backend/app/modules/coach/service.py b/backend/app/modules/coach/service.py index cba549d72d3419bb82a7f2a67cc447338a1e3bae..426d684bf85980641af934bdd0ad9df52294ca8c 100644 --- a/backend/app/modules/coach/service.py +++ b/backend/app/modules/coach/service.py @@ -8,7 +8,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import Staff, require_player, sessions_shared, visible_players_query from app.common.schemas import Page from app.core.errors import Forbidden -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.integrations.storage import StorageClient from app.modules.accounts.models import Account from app.modules.coach.repository import ( @@ -74,10 +74,7 @@ class CoachService: raise Forbidden("This player does not share sessions with coaches.", code="SESSIONS_PRIVATE") query = player_sessions_query(player_id, mode, paging.cursor, paging.limit + 1) items = await load_summaries(self.db, self.storage, query) - next_cursor = None - if len(items) > paging.limit: - items = items[:paging.limit] - next_cursor = encode_cursor(items[-1].created_at, items[-1].id) + items, next_cursor = paginate(items, paging.limit) return Page[SessionSummary](items=items, next_cursor=next_cursor) async def queue(self, staff: Staff, since: datetime | None) -> QueueResponse: diff --git a/backend/app/modules/goals/service.py b/backend/app/modules/goals/service.py index c5ca003c6abc2b06a83389fbdb7caf33e081fd2b..2d8f88bd1ceb1a8e3ae9ba48c391c1110d77e8ab 100644 --- a/backend/app/modules/goals/service.py +++ b/backend/app/modules/goals/service.py @@ -13,7 +13,7 @@ from app.common.academy_access import Staff, can_see_player, require_player, sta from app.common.notify import notify from app.common.schemas import Page from app.core.errors import Conflict, Forbidden, NotFound, ValidationFailed -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.integrations.push import PushClient from app.modules.accounts.models import Account from app.modules.goals.models import Goal @@ -169,20 +169,16 @@ class GoalService: async def history(self, account: Account, player_id: UUID, mode: str, paging: PageParams) -> Page[GoalHistoryOut]: team_id = await self._authorize_read(account, player_id) rows = list(await self.goals.ended(player_id, mode, paging.cursor, paging.limit, team_id=team_id)) - page = rows[:paging.limit] + page, next_cursor = paginate(rows, paging.limit) items = [GoalHistoryOut(id=g.id, text=_text(g), range=_range(g), met=_met(g), outcome=g.outcome, start_at=g.created_at, end_at=g.ended_at, evaluated_session_id=g.evaluated_session_id) for g in page] - more = len(rows) > paging.limit - return Page[GoalHistoryOut](items=items, next_cursor=encode_cursor(page[-1].created_at, page[-1].id) - if more else None) + return Page[GoalHistoryOut](items=items, next_cursor=next_cursor) async def milestones(self, account: Account, mode: str, paging: PageParams) -> Page[MilestoneOut]: rows = list(await self.goals.ended(account.id, mode, paging.cursor, paging.limit, met_only=True)) - page = rows[:paging.limit] + page, next_cursor = paginate(rows, paging.limit) items = [MilestoneOut(id=g.id, icon="flag", tone="b", title=f"Goal met: {_text(g)}", when=_fmt(g.ended_at, True), occurred_at=g.ended_at, source_goal_id=g.id) # type: ignore[arg-type] for g in page] - more = len(rows) > paging.limit - return Page[MilestoneOut](items=items, next_cursor=encode_cursor(page[-1].created_at, page[-1].id) - if more else None) + return Page[MilestoneOut](items=items, next_cursor=next_cursor) diff --git a/backend/app/modules/idempotency/service.py b/backend/app/modules/idempotency/service.py index 6bd2be48e15a09e02ed7f0c2c9c2278a1bcacf4d..bc46049856200204dcb3100fa4d2ca234794e8dc 100644 --- a/backend/app/modules/idempotency/service.py +++ b/backend/app/modules/idempotency/service.py @@ -6,6 +6,7 @@ Usage in a controller: The first call runs the handler and stores its response; a retry with the same key and body replays it; the same key with a different body is a 409. +Pass scope= when the route has a target id, so one key cannot replay across targets. """ import hashlib @@ -22,8 +23,11 @@ from app.core.errors import Conflict from app.modules.idempotency.models import IdempotencyKey -def _hash(body: BaseModel) -> str: - return hashlib.sha256(json.dumps(body.model_dump(mode="json"), sort_keys=True).encode()).hexdigest() +def _hash(body: BaseModel, scope: UUID | None) -> str: + payload = body.model_dump(mode="json") + if scope is not None: + payload = {"target": str(scope), "body": payload} + return hashlib.sha256(json.dumps(payload, sort_keys=True).encode()).hexdigest() async def run_idempotent( @@ -34,10 +38,11 @@ async def run_idempotent( handler: Callable[[], Awaitable[BaseModel]], *, status_code: int, + scope: UUID | None = None, ) -> JSONResponse: if not key: return JSONResponse(jsonable_encoder(await handler()), status_code=status_code) - request_hash = _hash(body) + request_hash = _hash(body, scope) stored = await db.get(IdempotencyKey, (account_id, key)) if stored is not None: if stored.request_hash != request_hash: diff --git a/backend/app/modules/notifications/service.py b/backend/app/modules/notifications/service.py index 0a3ab248dc0f65eda13aa33404a666c1e2b8c230..7d9585e1863b54b6fe18c694e5eec490d9b645b3 100644 --- a/backend/app/modules/notifications/service.py +++ b/backend/app/modules/notifications/service.py @@ -7,7 +7,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from app.common.schemas import Page from app.core.errors import NotFound -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.modules.accounts.models import Account from app.modules.notifications.repository import NotificationRepository from app.modules.notifications.schemas import NotificationOut, UnreadCount @@ -19,10 +19,9 @@ class NotificationService: async def list(self, account: Account, paging: PageParams) -> Page[NotificationOut]: rows = await self.notifications.page(account.id, paging.cursor, paging.limit + 1) - next_cursor = encode_cursor(rows[paging.limit - 1].created_at, rows[paging.limit - 1].id) \ - if len(rows) > paging.limit else None + page, next_cursor = paginate(rows, paging.limit) items = [NotificationOut(id=r.id, kind=r.kind, title=r.title, body=r.body, at=r.created_at, - read=r.read_at is not None, target=r.target) for r in rows[:paging.limit]] + read=r.read_at is not None, target=r.target) for r in page] return Page[NotificationOut](items=items, next_cursor=next_cursor) async def unread_count(self, account: Account) -> UnreadCount: diff --git a/backend/app/modules/reporting/service.py b/backend/app/modules/reporting/service.py index cadf54a771ce8d588890cbd1d3cff8f2f35a6fc2..460cbac28b53b7bb9e02eea7c3974bf5627bce83 100644 --- a/backend/app/modules/reporting/service.py +++ b/backend/app/modules/reporting/service.py @@ -22,12 +22,12 @@ import re import uuid from datetime import UTC, datetime, timedelta -import httpx from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import Staff +from app.common.labels import FOCUS_LABEL, tone_counts from app.core.errors import Conflict, Forbidden, NotFound, ValidationFailed -from app.core.pagination import Cursor, encode_cursor +from app.core.pagination import Cursor, paginate from app.integrations.storage import StorageClient from app.modules.reporting.repository import ReportingRepository from app.modules.reporting.schemas import ( @@ -47,7 +47,6 @@ from app.modules.reporting.schemas import ( REVENUE_UNAVAILABLE = "Revenue ledger not configured" EXPORT_MAX_ROWS = 5000 _MONTH = re.compile(r"^(\d{4})-(0[1-9]|1[0-2])$") -_FOCUS = {"h": "Hitting", "p": "Pitching", "both": "Both"} _FORMULA_PREFIX = ("=", "+", "-", "@", "\t", "\r") @@ -89,7 +88,7 @@ class ReportingService: denominator, improved = await repo.improving(team, start, end) scores = await repo.latest_scores(team, end) reviews = await repo.reviews_by_coach(team, start, end) - coaches = [CoachActivity(id=cid, name=name, coaches=_FOCUS.get(focus, "Both"), reviews=reviews.get(cid, 0)) + coaches = [CoachActivity(id=cid, name=name, coaches=FOCUS_LABEL.get(focus, "Both"), reviews=reviews.get(cid, 0)) for cid, name, focus in await repo.coach_rows(team)] return DashboardResponse(dashboard=Dashboard( month=label, @@ -98,8 +97,7 @@ class ReportingService: improving_pct=round(100 * improved / denominator) if denominator else None, analyses_this_week=await repo.analyses_since(team, now - timedelta(days=7)), avg_review_hours=await repo.avg_review_hours(team, start, end), - cards=Cards(g=sum(s >= 80 for s in scores), y=sum(60 <= s < 80 for s in scores), - r=sum(s < 60 for s in scores)), + cards=Cards(**tone_counts(scores)), coaches=coaches, pending_requests=await repo.pending_requests(team), not_filmed_7d=await repo.not_filmed_since(team, now - timedelta(days=7)), @@ -141,8 +139,7 @@ class ReportingService: await self._scope(staff, group_id) accepted, ai_opt_in = await self.repo.consent_totals(staff.team_id, group_id) rows = await self.repo.consent_rows(staff.team_id, group_id, limit + 1, cursor) - page = rows[:limit] - next_cursor = encode_cursor(page[-1]["created_at"], page[-1]["player_id"]) if len(rows) > limit else None + page, next_cursor = paginate(rows, limit, lambda r: (r["created_at"], r["player_id"])) return ConsentPage(items=[self._item(r) for r in page], next_cursor=next_cursor, accepted=accepted, ai_opt_in=ai_opt_in) @@ -168,10 +165,7 @@ class ReportingService: now = datetime.now(UTC) export_id = uuid.uuid4() key = f"exports/{staff.team_id}/{export_id}.csv" - async with httpx.AsyncClient() as http: - response = await http.put(self.storage.presign_put(key, "text/csv"), content=buffer.getvalue().encode(), - headers={"Content-Type": "text/csv"}) - response.raise_for_status() + await self.storage.put_bytes(key, buffer.getvalue().encode(), "text/csv") expires_at = now + timedelta(seconds=self.storage.download_ttl) filename = f"consent-{now:%Y-%m-%d}.csv" job = await self.repo.add_export(id=export_id, requester_id=staff.id, team_id=staff.team_id, diff --git a/backend/app/modules/reviews/repository.py b/backend/app/modules/reviews/repository.py index 0ba4389ebb7c1842d131f5adfc7a5897d1e8830a..53c39abd619bfc845bcfe6f3cd7fd124bcaea228 100644 --- a/backend/app/modules/reviews/repository.py +++ b/backend/app/modules/reviews/repository.py @@ -46,9 +46,6 @@ class ReviewRepository(BaseRepository[Review]): async def upload(self, upload_id: UUID) -> Upload | None: return await self.session.get(Upload, upload_id) - async def locked_upload(self, upload_id: UUID) -> Upload | None: - return await self.session.scalar(select(Upload).where(Upload.id == upload_id).with_for_update()) - async def locked_session_thread(self, session: SwingSession, coach_id: UUID, team_id: UUID | None) -> Thread: """The session's one thread, created if missing, locked for the counter update.""" query = select(Thread).where(Thread.session_id == session.id).with_for_update() diff --git a/backend/app/modules/reviews/service.py b/backend/app/modules/reviews/service.py index cd47fa6e62a5f635b9a9d3220297bce6311c27dd..83a48924c797fe6a2703bccb46aa905be0d22b6d 100644 --- a/backend/app/modules/reviews/service.py +++ b/backend/app/modules/reviews/service.py @@ -6,30 +6,22 @@ number so the player sees it as unread again) and the notification. import hashlib import json -from datetime import UTC, datetime, timedelta -from functools import cache from uuid import UUID from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import Staff, can_see_player, sessions_shared +from app.common.labels import DISCIPLINES, drill_catalog +from app.common.media import upload_ref from app.common.notify import notify from app.common.schemas import MediaRef +from app.common.uploads import UploadErrors, claim_upload from app.core.errors import Conflict, Forbidden, NotFound, Unprocessable, ValidationFailed from app.integrations.push import PushClient from app.integrations.storage import StorageClient from app.modules.reviews.repository import ReviewRepository from app.modules.reviews.schemas import ReviewOut, ReviewSubmit, ReviewSubmitted -_DISCIPLINES = {"h": "hitting", "p": "pitching"} - - -@cache -def drill_ids(discipline: str) -> frozenset[str]: - from ai_coach.knowledge import all_drills - - return frozenset(d["id"] for d in all_drills() if d["discipline"] == discipline) - def _content_key(values: dict) -> str: """Same review content -> same key, so a byte-identical resend never notifies twice.""" @@ -56,7 +48,7 @@ class ReviewService: raise Forbidden() fields: dict[str, str] = {} - if body.drill_id not in drill_ids(_DISCIPLINES[session.mode]): + if drill_catalog().get(body.drill_id, {}).get("discipline") != DISCIPLINES[session.mode]: fields["drill_id"] = "Unknown drill for this session." metric_ids = {m.get("metric_id") for m in (session.report or {}).get("measurements", [])} for key in body.verdicts: @@ -107,24 +99,20 @@ class ReviewService: return {"voice_upload_id": upload_id, "voice_seconds": seconds} async def _claim_audio(self, coach_id: UUID, upload_id: UUID, session_id: UUID) -> None: - upload = await self.repo.locked_upload(upload_id) - if upload is None or upload.owner_id != coach_id or upload.kind != "audio": - raise Unprocessable("Not a valid audio upload.", code="INVALID_UPLOAD") - if await self.storage.head(upload.object_key) is None: - raise Conflict("The upload has not finished. Please try again.", code="UPLOAD_NOT_READY") - if upload.attached_at is not None: + async def own_voice_note() -> bool: # the same review re-sending its own voice note current = await self.repo.get(session_id) - if current is None or current.voice_upload_id != upload_id: - raise Unprocessable("This audio was already used.", code="UPLOAD_ALREADY_USED") - return # the same review re-sending its own voice note - await self.repo.update(upload, attached_at=datetime.now(UTC)) + return current is not None and current.voice_upload_id == upload_id + + await claim_upload( + self.db, self.storage, upload_id, owner_id=coach_id, kind="audio", + errors=UploadErrors( + invalid=Unprocessable("Not a valid audio upload.", code="INVALID_UPLOAD"), + used=Unprocessable("This audio was already used.", code="UPLOAD_ALREADY_USED"), + not_ready=Conflict("The upload has not finished. Please try again.", code="UPLOAD_NOT_READY")), + reusable=own_voice_note) async def _voice_ref(self, review) -> MediaRef | None: if review.voice_upload_id is None: return None - upload = await self.repo.upload(review.voice_upload_id) - if upload is None: - return None - return MediaRef(upload_id=upload.id, url=self.storage.presign_get(upload.object_key), - expires_at=datetime.now(UTC) + timedelta(seconds=self.storage.download_ttl), - seconds=float(review.voice_seconds) if review.voice_seconds is not None else None) + seconds = float(review.voice_seconds) if review.voice_seconds is not None else None + return upload_ref(self.storage, await self.repo.upload(review.voice_upload_id), seconds) diff --git a/backend/app/modules/sessions/repository.py b/backend/app/modules/sessions/repository.py index e8c0d326775f0af94fd5d94dde5164ead6e5fa4a..dbdc3e60c4e46e9d3304fa4b150ec0cef143702c 100644 --- a/backend/app/modules/sessions/repository.py +++ b/backend/app/modules/sessions/repository.py @@ -9,7 +9,6 @@ from app.modules.accounts.models import Account from app.modules.reviews.models import Review from app.modules.sessions.models import SwingSession from app.modules.sessions.summary import summary_query -from app.modules.settings.models import ConsentEvent from app.modules.uploads.models import Upload @@ -53,14 +52,6 @@ class SessionRepository(BaseRepository[SwingSession]): .where(Review.session_id == session_id))).first() return (row[0], row[1] or "") if row else None - async def analysis_consent_blocked(self, account_id: UUID, require_accepted: bool) -> bool: - """True when the latest analysis consent is a withdrawal, or (when required) there is no acceptance.""" - action = await self.session.scalar( - select(ConsentEvent.action) - .where(ConsentEvent.account_id == account_id, ConsentEvent.category == "analysis") - .order_by(ConsentEvent.created_at.desc(), ConsentEvent.id.desc()).limit(1)) - return action == "withdrawn" or (require_accepted and action is None) - def summaries_query(self, owner_id: UUID, *, mode: str | None, is_self: bool | None, athlete_name: str | None, since: datetime | None, cursor: Cursor | None, limit: int) -> Select: query = summary_query().where(SwingSession.owner_id == owner_id) diff --git a/backend/app/modules/sessions/service.py b/backend/app/modules/sessions/service.py index 66c0bd79c5da7a26b0fe368b6a6b2a7445959cca..d249c73e65fccb6070be5aa371edfb6ddf67cfd8 100644 --- a/backend/app/modules/sessions/service.py +++ b/backend/app/modules/sessions/service.py @@ -8,10 +8,12 @@ from uuid import UUID from sqlalchemy.ext.asyncio import AsyncSession from app.common.academy_access import can_see_player, sessions_shared, staff_context -from app.common.schemas import MediaRef, Page +from app.common.consent import analysis_consent_blocked +from app.common.media import media_ref +from app.common.schemas import Page from app.core.config import get_settings from app.core.errors import Forbidden, NotFound, Unprocessable, ValidationFailed -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.integrations.storage import StorageClient from app.modules.accounts.models import Account from app.modules.billing.entitlement import EntitlementService @@ -91,7 +93,7 @@ class SessionService: # D2 async def create(self, account: Account, body: SessionIn) -> SessionOut: validate_marks(body) - if await self.sessions.analysis_consent_blocked(account.id, get_settings().require_analysis_consent): + if await analysis_consent_blocked(self.db, account.id, get_settings().require_analysis_consent): raise Forbidden("Please accept the analysis consent to continue.", code="CONSENT_REQUIRED") await EntitlementService(self.db).ensure_can_analyze(account.id) @@ -161,10 +163,8 @@ class SessionService: if r.voice_upload_id is not None: voice_keys = await self.uploads.object_keys(r.voice_upload_id) if r.voice_upload_id in voice_keys: - voice_note = MediaRef( - upload_id=r.voice_upload_id, url=self.storage.presign_get(voice_keys[r.voice_upload_id]), - expires_at=datetime.now(UTC) + timedelta(seconds=self.storage.download_ttl), - seconds=float(r.voice_seconds) if r.voice_seconds is not None else None) + voice_note = media_ref(self.storage, r.voice_upload_id, voice_keys[r.voice_upload_id], + float(r.voice_seconds) if r.voice_seconds is not None else None) review = ReviewOut(coach_id=r.coach_id, coach_name=coach_name, cue=r.cue, drill_id=r.drill_id, verdicts=r.verdicts, at=r.updated_at, voice_note=voice_note) previous = await self.sessions.previous(s) @@ -191,10 +191,7 @@ class SessionService: query = self.sessions.summaries_query(owner.id, mode=mode, is_self=is_self, athlete_name=athlete_name, since=since, cursor=paging.cursor, limit=paging.limit + 1) items = await load_summaries(self.db, self.storage, query) - next_cursor = None - if len(items) > paging.limit: - items = items[:paging.limit] - next_cursor = encode_cursor(items[-1].created_at, items[-1].id) + items, next_cursor = paginate(items, paging.limit) return Page[SessionSummary](items=items, next_cursor=next_cursor) # D5 diff --git a/backend/app/modules/swing_reports/repository.py b/backend/app/modules/swing_reports/repository.py index ff1f0d11d76cd96be78f2b574ae675e8e7ff1925..5f934d20c5b8af29c15f3bf74d241bf42d45a707 100644 --- a/backend/app/modules/swing_reports/repository.py +++ b/backend/app/modules/swing_reports/repository.py @@ -4,7 +4,6 @@ from sqlalchemy import select from app.common.base_repository import BaseRepository from app.modules.sessions.models import SwingSession -from app.modules.settings.models import ConsentEvent class SwingReportRepository(BaseRepository[SwingSession]): @@ -16,11 +15,3 @@ class SwingReportRepository(BaseRepository[SwingSession]): select(SwingSession).where(SwingSession.id == session_id, SwingSession.deleted_at.is_(None)) .with_for_update()) return result.scalars().first() - - async def analysis_consent_blocked(self, account_id: UUID, require_accepted: bool) -> bool: - """True when the latest analysis consent is a withdrawal, or (when required) there is no acceptance.""" - action = await self.session.scalar( - select(ConsentEvent.action) - .where(ConsentEvent.account_id == account_id, ConsentEvent.category == "analysis") - .order_by(ConsentEvent.created_at.desc(), ConsentEvent.id.desc()).limit(1)) - return action == "withdrawn" or (require_accepted and action is None) diff --git a/backend/app/modules/swing_reports/service.py b/backend/app/modules/swing_reports/service.py index f534344a1620b140830af83d67d42dbde21802a9..96a10f7427946fc896ffe362c2da8b530dcf2a98 100644 --- a/backend/app/modules/swing_reports/service.py +++ b/backend/app/modules/swing_reports/service.py @@ -15,6 +15,7 @@ from ai_coach.config import get_settings as get_coach_settings from ai_coach.swing_report import AthleteContext, InvalidPayload, build_report, validate_payload from sqlalchemy.ext.asyncio import AsyncSession +from app.common.consent import analysis_consent_blocked from app.core.config import get_settings from app.core.errors import Conflict, Forbidden, NotFound, ServiceUnavailable, Unprocessable from app.modules.accounts.models import Account @@ -68,8 +69,8 @@ class SwingReportService: # Validation is cheap and runs first, so a broken payload never reaches the plan check or the model. parsed, problems = validate_payload(payload) if parsed is None: - raise Unprocessable("The payload does not follow swing analysis contract 1.0.", code="INVALID_PAYLOAD", - fields=problems) + raise Unprocessable("The payload does not follow swing analysis contract 1.0 or 1.1.", + code="INVALID_PAYLOAD", fields=problems) if session.report is not None: if session.analysis_id != parsed.analysis_id: @@ -78,7 +79,7 @@ class SwingReportService: return session.report if parsed.analysis_revision < (session.analysis_revision or 0): raise Conflict("A newer revision of this analysis has already been reported.", code="STALE_REVISION") - if await self.sessions.analysis_consent_blocked(account.id, get_settings().require_analysis_consent): + if await analysis_consent_blocked(self.db, account.id, get_settings().require_analysis_consent): raise Forbidden("Please accept the analysis consent to continue.", code="CONSENT_REQUIRED") ensure_coach_configured() if session.analyzed_at is None: @@ -90,7 +91,17 @@ class SwingReportService: except InvalidPayload as exc: # defensive: the builder re-validates raise Unprocessable(str(exc), code="INVALID_PAYLOAD", fields=exc.problems) from exc + marks = dict(session.marks or {}) + for event_name, mark_name in (("stride_start", "stride_start_frame"), + ("front_foot_down", "stride_end_frame"), ("contact", "contact_frame")): + event = getattr(parsed.events, event_name) + if event.status != "unavailable" and event.source_frame_index is not None: + marks[mark_name] = event.source_frame_index + if event_name == "contact": + marks["contact_offset"] = 0 + marks["contact_source"] = "manual" if event.source == "manual_review" else "detected" await self.sessions.update( session, measurement_payload=payload, report=report, analysis_id=parsed.analysis_id, - analysis_revision=parsed.analysis_revision, analyzed_at=session.analyzed_at or datetime.now(UTC)) + analysis_revision=parsed.analysis_revision, marks=marks, + analyzed_at=session.analyzed_at or datetime.now(UTC)) return report diff --git a/backend/app/modules/threads/controller.py b/backend/app/modules/threads/controller.py index b05fb0543a2ac3286b1d7dfdcb84e57de8d3a768..bf0eb1831d7b78bc228fe39ef4a3ef55cf28de4b 100644 --- a/backend/app/modules/threads/controller.py +++ b/backend/app/modules/threads/controller.py @@ -4,7 +4,6 @@ from typing import Annotated from uuid import UUID from fastapi import APIRouter, Depends, Header, Query, Response, status -from pydantic import BaseModel from app.common.academy_access import CurrentStaff from app.common.schemas import Page @@ -22,11 +21,6 @@ def get_thread_service(db: Db, storage: Storage, return ThreadService(db, storage, push) -class _Scoped(BaseModel): - thread_id: str - body: dict - - Service = Annotated[ThreadService, Depends(get_thread_service)] @@ -59,9 +53,8 @@ async def mark_read(thread_id: UUID, body: ReadIn, account: CurrentAccount, serv async def send_message(thread_id: UUID, body: MessageIn, account: CurrentAccount, db: Db, service: Service, idempotency_key: Annotated[str | None, Header()] = None): # The key is scoped to the account, so the thread id is part of what must match on replay. - scoped = _Scoped(thread_id=str(thread_id), body=body.model_dump(mode="json")) - return await run_idempotent(db, account.id, idempotency_key, scoped, lambda: service.send(account, thread_id, body), - status_code=status.HTTP_201_CREATED) + return await run_idempotent(db, account.id, idempotency_key, body, lambda: service.send(account, thread_id, body), + status_code=status.HTTP_201_CREATED, scope=thread_id) @router.post("/coach/players/{player_id}/thread", status_code=status.HTTP_201_CREATED, diff --git a/backend/app/modules/threads/repository.py b/backend/app/modules/threads/repository.py index 64641ba49c5d591638b43d23084d190f9fb3e1e6..7c008cbe22f6c2280b684b461e92d8e83a2d8f20 100644 --- a/backend/app/modules/threads/repository.py +++ b/backend/app/modules/threads/repository.py @@ -9,7 +9,7 @@ from sqlalchemy.dialects.postgresql import insert from sqlalchemy.orm import aliased from app.common.base_repository import BaseRepository -from app.modules.accounts.models import Account +from app.common.names import account_names from app.modules.reviews.models import Review from app.modules.sessions.models import SwingSession from app.modules.threads.models import Message, Thread @@ -91,8 +91,7 @@ class ThreadRepository(BaseRepository[Thread]): update(Thread).where(Thread.id == thread_id).values({column.key: func.greatest(column, seq)})) async def names(self, ids: set[UUID]) -> dict[UUID, str]: - rows = await self.session.execute(select(Account.id, Account.name).where(Account.id.in_(ids))) - return {i: n or "" for i, n in rows.all()} + return {i: n or "" for i, n in (await account_names(self.session, ids)).items()} async def session_row(self, session_id: UUID) -> SwingSession | None: return await self.session.get(SwingSession, session_id) @@ -122,12 +121,6 @@ class ThreadRepository(BaseRepository[Thread]): return {} return {u.id: u for u in await self.session.scalars(select(Upload).where(Upload.id.in_(ids)))} - async def upload(self, upload_id: UUID) -> Upload | None: - return await self.session.get(Upload, upload_id) - - async def locked_upload(self, upload_id: UUID) -> Upload | None: - return await self.session.scalar(select(Upload).where(Upload.id == upload_id).with_for_update()) - async def upload_in_use(self, upload_id: UUID) -> bool: """Backstop for rows attached before attached_at was reliably set.""" used = await self.session.scalar(select(Message.id).where(Message.upload_id == upload_id).limit(1)) diff --git a/backend/app/modules/threads/service.py b/backend/app/modules/threads/service.py index 1b947ed9a435df8e5a323659c106aeab3e85bbba..7d84163e15484ff525440161086129697bed5226 100644 --- a/backend/app/modules/threads/service.py +++ b/backend/app/modules/threads/service.py @@ -7,8 +7,7 @@ Thread.last_seq is the counter, incremented under a row lock. """ from dataclasses import dataclass -from datetime import UTC, datetime, timedelta -from functools import cache +from datetime import UTC, datetime from uuid import UUID from sqlalchemy.ext.asyncio import AsyncSession @@ -21,10 +20,13 @@ from app.common.academy_access import ( staff_context, visible_players_query, ) +from app.common.labels import drill_catalog, tone +from app.common.media import upload_ref from app.common.notify import notify from app.common.schemas import MediaRef, Page +from app.common.uploads import UploadErrors, claim_upload from app.core.errors import Conflict, Forbidden, NotFound, Unprocessable -from app.core.pagination import PageParams, encode_cursor +from app.core.pagination import PageParams, paginate from app.integrations.push import PushClient from app.integrations.storage import StorageClient from app.modules.accounts.models import Account @@ -46,24 +48,9 @@ from app.modules.threads.schemas import ( from app.modules.uploads.models import Upload LIST_MESSAGES = 20 # messages included per thread in the list -TONE_GREEN_MIN = 80 # overall score at or above: "g"; at or above TONE_YELLOW_MIN: "y"; below: "r" -TONE_YELLOW_MIN = 60 _SESSION_WORD = {"h": "Swing", "p": "Pitch"} -@cache -def drill_names() -> dict[str, str]: - from ai_coach.knowledge import all_drills - - return {d["id"]: d["name"] for d in all_drills()} - - -def tone(score: int | None) -> str: - if score is None: - return "y" - return "g" if score >= TONE_GREEN_MIN else "y" if score >= TONE_YELLOW_MIN else "r" - - @dataclass class Access: thread: Thread @@ -110,9 +97,8 @@ class ThreadService: team_id=scoped.team_id if scoped else None, visible=visible, mode=mode, filter_player_id=player_id, unread=unread, cursor_at=cursor.created_at if cursor else None, cursor_id=cursor.id if cursor else None, limit=paging.limit + 1)) - page = list(rows[:paging.limit]) + page, next_cursor = paginate(rows, paging.limit, lambda t: (t.updated_at, t.id)) out = await self._render(page, LIST_MESSAGES) - next_cursor = encode_cursor(page[-1].updated_at, page[-1].id) if len(rows) > paging.limit else None return Page[ThreadOut](items=out, next_cursor=next_cursor) async def get(self, account: Account, thread_id: UUID, cursor: str | None, limit: int) -> ThreadOut: @@ -191,14 +177,13 @@ class ThreadService: return (await self._render([thread], LIST_MESSAGES))[0], created async def _claim_audio(self, account: Account, upload_id: UUID) -> None: - upload = await self.repo.locked_upload(upload_id) - if upload is None or upload.owner_id != account.id or upload.kind != "audio": - raise Unprocessable("Not a valid audio upload.", code="INVALID_UPLOAD") - if upload.attached_at is not None or await self.repo.upload_in_use(upload_id): - raise Unprocessable("This audio was already used.", code="UPLOAD_ALREADY_USED") - if await self.storage.head(upload.object_key) is None: - raise Conflict("The upload has not finished. Please try again.", code="UPLOAD_NOT_READY") - await self.repo.update(upload, attached_at=datetime.now(UTC)) + await claim_upload( + self.db, self.storage, upload_id, owner_id=account.id, kind="audio", + errors=UploadErrors( + invalid=Unprocessable("Not a valid audio upload.", code="INVALID_UPLOAD"), + used=Unprocessable("This audio was already used.", code="UPLOAD_ALREADY_USED"), + not_ready=Conflict("The upload has not finished. Please try again.", code="UPLOAD_NOT_READY")), + in_use=lambda: self.repo.upload_in_use(upload_id)) async def _check_session(self, access: Access, session_id: UUID) -> None: session = await self.repo.session_row(session_id) @@ -279,7 +264,7 @@ class ThreadService: return ReviewMessageOut( **common, cue=review.cue, voice_seconds=seconds, audio=ctx.media(review.voice_upload_id, seconds), findings=_findings(review, session), drill_id=review.drill_id, - drill_name=drill_names().get(review.drill_id)) + drill_name=drill_catalog().get(review.drill_id, {}).get("name")) @dataclass @@ -292,10 +277,7 @@ class _Context: def media(self, upload_id: UUID | None, seconds: float | None) -> MediaRef | None: upload = self.uploads.get(upload_id) if upload_id else None - if upload is None: - return None - return MediaRef(upload_id=upload.id, url=self.storage.presign_get(upload.object_key), - expires_at=datetime.now(UTC) + timedelta(seconds=self.storage.download_ttl), seconds=seconds) + return upload_ref(self.storage, upload, seconds) def _label(session: SwingSession, ordinal: int) -> str: diff --git a/backend/docs/openapi.json b/backend/docs/openapi.json index b5244e91e83958b824fd71e6b87229be76e26c70..3f62cc747a4bcf82646bed0b909ada51039deae0 100644 --- a/backend/docs/openapi.json +++ b/backend/docs/openapi.json @@ -915,7 +915,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SessionIn" + "$ref": "#/components/schemas/app__modules__sessions__schemas__SessionIn" } } } @@ -1520,7 +1520,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ReviewCreate" + "$ref": "#/components/schemas/ReviewSubmit" } } } @@ -1531,7 +1531,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ReviewResponse" + "$ref": "#/components/schemas/ReviewSubmitted" } } } @@ -1567,6 +1567,23 @@ "summary": "Roster", "operationId": "roster_v1_coach_roster_get", "parameters": [ + { + "name": "group_id", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Group Id" + } + }, { "name": "authorization", "in": "header", @@ -2579,325 +2596,9186 @@ } } } - } - }, - "components": { - "schemas": { - "AppleWebhookIn": { - "properties": { - "signedPayload": { - "type": "string", - "maxLength": 200000, - "title": "Signedpayload" + }, + "/v1/me/settings": { + "get": { + "tags": [ + "settings" + ], + "summary": "Read Settings", + "operationId": "read_settings_v1_me_settings_get", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } } - }, - "type": "object", - "required": [ - "signedPayload" ], - "title": "AppleWebhookIn" - }, - "AthleteIn": { - "properties": { - "name": { - "type": "string", - "maxLength": 80, - "minLength": 2, - "title": "Name" - }, - "age": { - "type": "integer", - "maximum": 70.0, - "minimum": 5.0, - "title": "Age" - }, - "height_cm": { - "type": "number", - "maximum": 230.0, - "minimum": 90.0, - "title": "Height Cm" - }, - "weight_kg": { - "type": "number", - "maximum": 200.0, - "minimum": 20.0, - "title": "Weight Kg" - }, - "bats": { - "type": "string", - "enum": [ - "L", - "R", - "S" - ], - "title": "Bats" + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettingsEnvelope" + } + } + } }, - "throws": { - "type": "string", - "enum": [ - "L", - "R" - ], - "title": "Throws" + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } }, - "level": { - "type": "string", - "enum": [ - "youth", - "high_school", - "college", - "adult" - ], - "title": "Level" + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "age", - "height_cm", - "weight_kg", - "bats", - "throws", - "level" - ], - "title": "AthleteIn" + } }, - "AuthOut": { - "properties": { - "user": { - "$ref": "#/components/schemas/UserOut" - }, - "tokens": { - "$ref": "#/components/schemas/TokensOut" + "patch": { + "tags": [ + "settings" + ], + "summary": "Update Settings", + "operationId": "update_settings_v1_me_settings_patch", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } } - }, - "type": "object", - "required": [ - "user", - "tokens" ], - "title": "AuthOut" - }, - "BenchmarkOut": { - "additionalProperties": false, - "properties": { - "benchmark_id": { - "title": "Benchmark Id", - "type": "string" - }, - "version": { - "title": "Version", - "type": "string" - }, - "population": { - "title": "Population", - "type": "string" - }, - "on_target": { - "$ref": "#/components/schemas/Interval" - }, - "satisfactory": { - "$ref": "#/components/schemas/Interval" - }, - "unit": { - "title": "Unit", - "type": "string" - }, - "source_reference": { - "title": "Source Reference", - "type": "string" + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettingsPatch" + } + } } }, - "required": [ - "benchmark_id", - "version", - "population", - "on_target", - "satisfactory", - "unit", - "source_reference" - ], - "title": "BenchmarkOut", - "type": "object" - }, - "CatalogOut": { - "properties": { - "groups": { - "items": { - "$ref": "#/components/schemas/GroupOut" - }, - "type": "array", - "title": "Groups" + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SettingsEnvelope" + } + } + } }, - "metrics": { - "items": { - "$ref": "#/components/schemas/MetricOut" - }, - "type": "array", - "title": "Metrics" + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } }, - "drills": { - "items": { - "$ref": "#/components/schemas/DrillOut" + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/consent": { + "post": { + "tags": [ + "settings" + ], + "summary": "Accept Consent", + "operationId": "accept_consent_v1_me_consent_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConsentIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": {} + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "delete": { + "tags": [ + "settings" + ], + "summary": "Withdraw Consent", + "operationId": "withdraw_consent_v1_me_consent_delete", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "204": { + "description": "Successful Response" + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/exports": { + "post": { + "tags": [ + "settings" + ], + "summary": "Request Export", + "operationId": "request_export_v1_me_exports_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExportIn" + } + } + } + }, + "responses": { + "202": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExportEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/notifications": { + "get": { + "tags": [ + "notifications" + ], + "summary": "List Notifications", + "operationId": "list_notifications_v1_notifications_get", + "parameters": [ + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_NotificationOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/notifications/unread-count": { + "get": { + "tags": [ + "notifications" + ], + "summary": "Unread Count", + "operationId": "unread_count_v1_notifications_unread_count_get", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UnreadCount" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/notifications/read-all": { + "post": { + "tags": [ + "notifications" + ], + "summary": "Read All", + "operationId": "read_all_v1_notifications_read_all_post", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/ReadAllIn" + }, + { + "type": "null" + } + ], + "title": "Body" + } + } + } + }, + "responses": { + "204": { + "description": "Successful Response" + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/notifications/{notification_id}/read": { + "post": { + "tags": [ + "notifications" + ], + "summary": "Read One", + "operationId": "read_one_v1_notifications__notification_id__read_post", + "parameters": [ + { + "name": "notification_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Notification Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "204": { + "description": "Successful Response" + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/threads": { + "get": { + "tags": [ + "threads" + ], + "summary": "List Threads", + "operationId": "list_threads_v1_threads_get", + "parameters": [ + { + "name": "mode", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "pattern": "^[hp]$" + }, + { + "type": "null" + } + ], + "title": "Mode" + } + }, + { + "name": "player_id", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Player Id" + } + }, + { + "name": "unread", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Unread" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_ThreadOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/threads/{thread_id}": { + "get": { + "tags": [ + "threads" + ], + "summary": "Get Thread", + "operationId": "get_thread_v1_threads__thread_id__get", + "parameters": [ + { + "name": "thread_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Thread Id" + } + }, + { + "name": "message_cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Message Cursor" + } + }, + { + "name": "message_limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 100, + "minimum": 1, + "default": 50, + "title": "Message Limit" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ThreadEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/sessions/{session_id}/thread": { + "get": { + "tags": [ + "threads" + ], + "summary": "Session Thread", + "operationId": "session_thread_v1_sessions__session_id__thread_get", + "parameters": [ + { + "name": "session_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Session Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ThreadEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/threads/{thread_id}/read": { + "post": { + "tags": [ + "threads" + ], + "summary": "Mark Read", + "operationId": "mark_read_v1_threads__thread_id__read_post", + "parameters": [ + { + "name": "thread_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Thread Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ReadIn" + } + } + } + }, + "responses": { + "204": { + "description": "Successful Response" + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/threads/{thread_id}/messages": { + "post": { + "tags": [ + "threads" + ], + "summary": "Send Message", + "operationId": "send_message_v1_threads__thread_id__messages_post", + "parameters": [ + { + "name": "thread_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Thread Id" + } + }, + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/TextIn" + }, + { + "$ref": "#/components/schemas/VoiceIn" + }, + { + "$ref": "#/components/schemas/app__modules__threads__schemas__SessionIn" + } + ], + "discriminator": { + "propertyName": "kind", + "mapping": { + "text": "#/components/schemas/TextIn", + "voice": "#/components/schemas/VoiceIn", + "session": "#/components/schemas/app__modules__threads__schemas__SessionIn" + } + }, + "title": "Body" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SendResult" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/coach/players/{player_id}/thread": { + "post": { + "tags": [ + "threads" + ], + "summary": "Ensure Thread", + "operationId": "ensure_thread_v1_coach_players__player_id__thread_post", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EnsureThreadIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ThreadEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/players/{player_id}/goals": { + "get": { + "tags": [ + "goals" + ], + "summary": "Get Goal", + "operationId": "get_goal_v1_players__player_id__goals_get", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "mode", + "in": "query", + "required": true, + "schema": { + "enum": [ + "h", + "p" + ], + "type": "string", + "title": "Mode" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GoalEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/players/{player_id}/goals/{mode}": { + "put": { + "tags": [ + "goals" + ], + "summary": "Put Goal", + "operationId": "put_goal_v1_players__player_id__goals__mode__put", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "mode", + "in": "path", + "required": true, + "schema": { + "enum": [ + "h", + "p" + ], + "type": "string", + "title": "Mode" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GoalIn" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GoalEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/players/{player_id}/goals/history": { + "get": { + "tags": [ + "goals" + ], + "summary": "Goal History", + "operationId": "goal_history_v1_players__player_id__goals_history_get", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "mode", + "in": "query", + "required": true, + "schema": { + "enum": [ + "h", + "p" + ], + "type": "string", + "title": "Mode" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_GoalHistoryOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/milestones": { + "get": { + "tags": [ + "goals" + ], + "summary": "Milestones", + "operationId": "milestones_v1_me_milestones_get", + "parameters": [ + { + "name": "mode", + "in": "query", + "required": true, + "schema": { + "enum": [ + "h", + "p" + ], + "type": "string", + "title": "Mode" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_MilestoneOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/drill-assignments": { + "get": { + "tags": [ + "assignments" + ], + "summary": "List Assignments", + "operationId": "list_assignments_v1_drill_assignments_get", + "parameters": [ + { + "name": "mode", + "in": "query", + "required": true, + "schema": { + "enum": [ + "h", + "p" + ], + "type": "string", + "title": "Mode" + } + }, + { + "name": "player_id", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Player Id" + } + }, + { + "name": "status", + "in": "query", + "required": false, + "schema": { + "enum": [ + "open", + "completed", + "all" + ], + "type": "string", + "default": "all", + "title": "Status" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_AssignmentOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/coach/players/{player_id}/drill-assignments": { + "post": { + "tags": [ + "assignments" + ], + "summary": "Assign Drill", + "operationId": "assign_drill_v1_coach_players__player_id__drill_assignments_post", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AssignIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AssignmentEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/drill-assignments/{assignment_id}/sets": { + "post": { + "tags": [ + "assignments" + ], + "summary": "Log Set", + "operationId": "log_set_v1_drill_assignments__assignment_id__sets_post", + "parameters": [ + { + "name": "assignment_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Assignment Id" + } + }, + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SetResult" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/arm-care": { + "get": { + "tags": [ + "arm-care" + ], + "summary": "Get Arm Care", + "operationId": "get_arm_care_v1_me_arm_care_get", + "parameters": [ + { + "name": "from", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "From" + } + }, + { + "name": "to", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "To" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArmCareEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/arm-care/outings": { + "post": { + "tags": [ + "arm-care" + ], + "summary": "Add Outing", + "operationId": "add_outing_v1_me_arm_care_outings_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OutingIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OutingResult" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/arm-care/feel": { + "put": { + "tags": [ + "arm-care" + ], + "summary": "Set Feel", + "operationId": "set_feel_v1_me_arm_care_feel_put", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FeelIn" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FeelOut" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/me/coach-access": { + "get": { + "tags": [ + "academy_staff" + ], + "summary": "Get Coach Access", + "operationId": "get_coach_access_v1_me_coach_access_get", + "parameters": [ + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoachAccessBody" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "post": { + "tags": [ + "academy_staff" + ], + "summary": "Apply For Coach Access", + "operationId": "apply_for_coach_access_v1_me_coach_access_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoachAccessCreate" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoachAccessBody" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/coaches": { + "get": { + "tags": [ + "academy_staff" + ], + "summary": "List Coaches", + "operationId": "list_coaches_v1_academy_coaches_get", + "parameters": [ + { + "name": "status", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "enum": [ + "active", + "paused", + "removed", + "all" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Status" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_CoachOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/coaches/{coach_id}": { + "get": { + "tags": [ + "academy_staff" + ], + "summary": "Get Coach", + "operationId": "get_coach_v1_academy_coaches__coach_id__get", + "parameters": [ + { + "name": "coach_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Coach Id" + } + }, + { + "name": "activity_from", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Activity From" + } + }, + { + "name": "activity_to", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Activity To" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoachBody" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "patch": { + "tags": [ + "academy_staff" + ], + "summary": "Update Coach", + "operationId": "update_coach_v1_academy_coaches__coach_id__patch", + "parameters": [ + { + "name": "coach_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Coach Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoachUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoachBody" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "delete": { + "tags": [ + "academy_staff" + ], + "summary": "Remove Coach", + "operationId": "remove_coach_v1_academy_coaches__coach_id__delete", + "parameters": [ + { + "name": "coach_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Coach Id" + } + }, + { + "name": "reassign_to", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Reassign To" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "204": { + "description": "Successful Response" + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/coach-requests": { + "get": { + "tags": [ + "academy_staff" + ], + "summary": "List Requests", + "operationId": "list_requests_v1_academy_coach_requests_get", + "parameters": [ + { + "name": "status", + "in": "query", + "required": false, + "schema": { + "enum": [ + "pending", + "approved", + "declined", + "all" + ], + "type": "string", + "default": "all", + "title": "Status" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RequestPage" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/coach-requests/{request_id}/decision": { + "post": { + "tags": [ + "academy_staff" + ], + "summary": "Decide Request", + "operationId": "decide_request_v1_academy_coach_requests__request_id__decision_post", + "parameters": [ + { + "name": "request_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Request Id" + } + }, + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DecisionIn" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DecisionOut" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/staff-codes": { + "get": { + "tags": [ + "academy_staff" + ], + "summary": "List Codes", + "operationId": "list_codes_v1_academy_staff_codes_get", + "parameters": [ + { + "name": "status", + "in": "query", + "required": false, + "schema": { + "enum": [ + "active", + "expired", + "revoked", + "all" + ], + "type": "string", + "default": "all", + "title": "Status" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_StaffCodeOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "post": { + "tags": [ + "academy_staff" + ], + "summary": "Create Code", + "operationId": "create_code_v1_academy_staff_codes_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StaffCodeCreate" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StaffCodeBody" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/staff-codes/{code}": { + "delete": { + "tags": [ + "academy_staff" + ], + "summary": "Revoke Code", + "operationId": "revoke_code_v1_academy_staff_codes__code__delete", + "parameters": [ + { + "name": "code", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "Code" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "204": { + "description": "Successful Response" + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/groups": { + "get": { + "tags": [ + "academy_org" + ], + "summary": "List Groups", + "operationId": "list_groups_v1_academy_groups_get", + "parameters": [ + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_GroupOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "post": { + "tags": [ + "academy_org" + ], + "summary": "Create Group", + "operationId": "create_group_v1_academy_groups_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GroupIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GroupEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/coach/players/{player_id}/note": { + "get": { + "tags": [ + "academy_org" + ], + "summary": "Get Note", + "operationId": "get_note_v1_coach_players__player_id__note_get", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NoteEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "put": { + "tags": [ + "academy_org" + ], + "summary": "Save Note", + "operationId": "save_note_v1_coach_players__player_id__note_put", + "parameters": [ + { + "name": "player_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid", + "title": "Player Id" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NoteIn" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NoteEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/members": { + "get": { + "tags": [ + "academy_org" + ], + "summary": "Members", + "operationId": "members_v1_academy_members_get", + "parameters": [ + { + "name": "q", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 100 + }, + { + "type": "null" + } + ], + "title": "Q" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_MemberOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/coach/roster/players": { + "post": { + "tags": [ + "academy_org" + ], + "summary": "Add Roster Players", + "operationId": "add_roster_players_v1_coach_roster_players_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RosterAddIn" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RosterAddOut" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/library": { + "get": { + "tags": [ + "academy_org" + ], + "summary": "Library", + "operationId": "library_v1_academy_library_get", + "parameters": [ + { + "name": "mode", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "enum": [ + "h", + "p" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Mode" + } + }, + { + "name": "fault_tag", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 64 + }, + { + "type": "null" + } + ], + "title": "Fault Tag" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Page_LibraryDrillOut_" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + }, + "post": { + "tags": [ + "academy_org" + ], + "summary": "Publish Drill", + "operationId": "publish_drill_v1_academy_library_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LibraryDrillIn" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LibraryEnvelope" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/dashboard": { + "get": { + "tags": [ + "reporting" + ], + "summary": "Dashboard", + "operationId": "dashboard_v1_academy_dashboard_get", + "parameters": [ + { + "name": "month", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Month" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DashboardResponse" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/earnings": { + "get": { + "tags": [ + "reporting" + ], + "summary": "Earnings", + "operationId": "earnings_v1_academy_earnings_get", + "parameters": [ + { + "name": "month", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Month" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EarningsResponse" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/corp": { + "get": { + "tags": [ + "reporting" + ], + "summary": "Corporate", + "operationId": "corporate_v1_academy_corp_get", + "parameters": [ + { + "name": "month", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Month" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CorporateResponse" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/consent": { + "get": { + "tags": [ + "reporting" + ], + "summary": "Consent", + "operationId": "consent_v1_academy_consent_get", + "parameters": [ + { + "name": "group_id", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Group Id" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 200, + "minimum": 1, + "default": 50, + "title": "Limit" + } + }, + { + "name": "cursor", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Cursor" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConsentPage" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/v1/academy/consent/export": { + "post": { + "tags": [ + "reporting" + ], + "summary": "Export Consent", + "operationId": "export_consent_v1_academy_consent_export_post", + "parameters": [ + { + "name": "idempotency-key", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string", + "maxLength": 128 + }, + { + "type": "null" + } + ], + "title": "Idempotency-Key" + } + }, + { + "name": "authorization", + "in": "header", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Authorization" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConsentExportRequest" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExportResponse" + } + } + } + }, + "400": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + }, + "default": { + "description": "Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AcademyOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "role": { + "type": "string", + "title": "Role" + }, + "status": { + "type": "string", + "title": "Status" + }, + "sees_all": { + "type": "boolean", + "title": "Sees All" + }, + "group_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Group Ids" + }, + "permissions": { + "additionalProperties": { + "type": "boolean" + }, + "type": "object", + "title": "Permissions" + } + }, + "type": "object", + "required": [ + "id", + "name", + "role", + "status", + "sees_all", + "group_ids", + "permissions" + ], + "title": "AcademyOut" + }, + "ActivityOut": { + "properties": { + "reviews": { + "type": "integer", + "title": "Reviews" + }, + "avg_reply_hours": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Avg Reply Hours" + }, + "players": { + "type": "integer", + "title": "Players" + }, + "drills_set": { + "type": "integer", + "title": "Drills Set" + }, + "period_start": { + "type": "string", + "format": "date", + "title": "Period Start" + }, + "period_end": { + "type": "string", + "format": "date", + "title": "Period End" + } + }, + "type": "object", + "required": [ + "reviews", + "avg_reply_hours", + "players", + "drills_set", + "period_start", + "period_end" + ], + "title": "ActivityOut" + }, + "AppleWebhookIn": { + "properties": { + "signedPayload": { + "type": "string", + "maxLength": 200000, + "title": "Signedpayload" + } + }, + "type": "object", + "required": [ + "signedPayload" + ], + "title": "AppleWebhookIn" + }, + "ArmCareEnvelope": { + "properties": { + "arm_care": { + "$ref": "#/components/schemas/ArmCareOut" + } + }, + "type": "object", + "required": [ + "arm_care" + ], + "title": "ArmCareEnvelope" + }, + "ArmCareOut": { + "properties": { + "outings": { + "items": { + "$ref": "#/components/schemas/OutingOut" + }, + "type": "array", + "title": "Outings" + }, + "feel": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Feel" + }, + "feel_recorded_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Feel Recorded At" + }, + "daily_max": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Daily Max" + }, + "innings_last_12_months": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Innings Last 12 Months" + }, + "innings_limit": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Innings Limit" + }, + "rest_status": { + "type": "string", + "title": "Rest Status", + "default": "unknown" + }, + "next_eligible_date": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Next Eligible Date" + }, + "rule_version": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Rule Version" + }, + "unavailable_reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Unavailable Reason", + "default": "Age-specific policy and innings source not configured" + } + }, + "type": "object", + "required": [ + "outings", + "feel", + "feel_recorded_at" + ], + "title": "ArmCareOut" + }, + "AssignIn": { + "properties": { + "mode": { + "type": "string", + "enum": [ + "h", + "p" + ], + "title": "Mode" + }, + "drill_source": { + "type": "string", + "enum": [ + "catalog", + "library" + ], + "title": "Drill Source" + }, + "drill_id": { + "type": "string", + "maxLength": 40, + "minLength": 1, + "title": "Drill Id" + }, + "due_date": { + "type": "string", + "format": "date", + "title": "Due Date" + }, + "source_session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Source Session Id" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "mode", + "drill_source", + "drill_id", + "due_date" + ], + "title": "AssignIn" + }, + "AssignmentEnvelope": { + "properties": { + "assignment": { + "$ref": "#/components/schemas/AssignmentOut" + } + }, + "type": "object", + "required": [ + "assignment" + ], + "title": "AssignmentEnvelope" + }, + "AssignmentOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "player_id": { + "type": "string", + "format": "uuid", + "title": "Player Id" + }, + "mode": { + "type": "string", + "title": "Mode" + }, + "drill_id": { + "type": "string", + "title": "Drill Id" + }, + "drill_source": { + "type": "string", + "title": "Drill Source" + }, + "name": { + "type": "string", + "title": "Name" + }, + "fixes": { + "type": "string", + "title": "Fixes" + }, + "sets": { + "type": "integer", + "title": "Sets" + }, + "reps": { + "type": "integer", + "title": "Reps" + }, + "due": { + "type": "string", + "title": "Due" + }, + "due_date": { + "type": "string", + "format": "date", + "title": "Due Date" + }, + "assigned_by": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Assigned By" + }, + "assigned_by_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Assigned By Id" + }, + "done": { + "type": "integer", + "title": "Done" + }, + "session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Session Id" + }, + "assigned_at": { + "type": "string", + "format": "date-time", + "title": "Assigned At" + }, + "media": { + "anyOf": [ + { + "$ref": "#/components/schemas/MediaRef" + }, + { + "type": "null" + } + ] + } + }, + "type": "object", + "required": [ + "id", + "player_id", + "mode", + "drill_id", + "drill_source", + "name", + "fixes", + "sets", + "reps", + "due", + "due_date", + "assigned_by", + "assigned_by_id", + "done", + "session_id", + "assigned_at", + "media" + ], + "title": "AssignmentOut" + }, + "AthleteIn": { + "properties": { + "name": { + "type": "string", + "maxLength": 80, + "minLength": 2, + "title": "Name" + }, + "age": { + "type": "integer", + "maximum": 70.0, + "minimum": 5.0, + "title": "Age" + }, + "height_cm": { + "type": "number", + "maximum": 230.0, + "minimum": 90.0, + "title": "Height Cm" + }, + "weight_kg": { + "type": "number", + "maximum": 200.0, + "minimum": 20.0, + "title": "Weight Kg" + }, + "bats": { + "type": "string", + "enum": [ + "L", + "R", + "S" + ], + "title": "Bats" + }, + "throws": { + "type": "string", + "enum": [ + "L", + "R" + ], + "title": "Throws" + }, + "level": { + "type": "string", + "enum": [ + "youth", + "high_school", + "college", + "adult" + ], + "title": "Level" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "age", + "height_cm", + "weight_kg", + "bats", + "throws", + "level" + ], + "title": "AthleteIn" + }, + "AuditLogDetail": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + }, + "started_at": { + "type": "string", + "format": "date-time", + "title": "Started At" + }, + "request_id": { + "type": "string", + "title": "Request Id" + }, + "method": { + "type": "string", + "title": "Method" + }, + "path": { + "type": "string", + "title": "Path" + }, + "route": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Route" + }, + "status_code": { + "type": "integer", + "title": "Status Code" + }, + "duration_ms": { + "type": "number", + "title": "Duration Ms" + }, + "account_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Account Id" + }, + "session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Session Id" + }, + "analysis_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Analysis Id" + }, + "analysis_revision": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Analysis Revision" + }, + "error_code": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Error Code" + }, + "exception_type": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Exception Type" + }, + "response_complete": { + "type": "boolean", + "title": "Response Complete" + }, + "service_version": { + "type": "string", + "title": "Service Version" + }, + "request_headers": { + "additionalProperties": true, + "type": "object", + "title": "Request Headers" + }, + "query_params": { + "additionalProperties": true, + "type": "object", + "title": "Query Params" + }, + "request_payload": { + "additionalProperties": true, + "type": "object", + "title": "Request Payload" + }, + "response_headers": { + "additionalProperties": true, + "type": "object", + "title": "Response Headers" + }, + "response_payload": { + "additionalProperties": true, + "type": "object", + "title": "Response Payload" + } + }, + "type": "object", + "required": [ + "id", + "created_at", + "started_at", + "request_id", + "method", + "path", + "route", + "status_code", + "duration_ms", + "account_id", + "session_id", + "analysis_id", + "analysis_revision", + "error_code", + "exception_type", + "response_complete", + "service_version", + "request_headers", + "query_params", + "request_payload", + "response_headers", + "response_payload" + ], + "title": "AuditLogDetail" + }, + "AuditLogSummary": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + }, + "started_at": { + "type": "string", + "format": "date-time", + "title": "Started At" + }, + "request_id": { + "type": "string", + "title": "Request Id" + }, + "method": { + "type": "string", + "title": "Method" + }, + "path": { + "type": "string", + "title": "Path" + }, + "route": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Route" + }, + "status_code": { + "type": "integer", + "title": "Status Code" + }, + "duration_ms": { + "type": "number", + "title": "Duration Ms" + }, + "account_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Account Id" + }, + "session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Session Id" + }, + "analysis_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Analysis Id" + }, + "analysis_revision": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Analysis Revision" + }, + "error_code": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Error Code" + }, + "exception_type": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Exception Type" + }, + "response_complete": { + "type": "boolean", + "title": "Response Complete" + }, + "service_version": { + "type": "string", + "title": "Service Version" + } + }, + "type": "object", + "required": [ + "id", + "created_at", + "started_at", + "request_id", + "method", + "path", + "route", + "status_code", + "duration_ms", + "account_id", + "session_id", + "analysis_id", + "analysis_revision", + "error_code", + "exception_type", + "response_complete", + "service_version" + ], + "title": "AuditLogSummary" + }, + "AuthOut": { + "properties": { + "user": { + "$ref": "#/components/schemas/UserOut" + }, + "tokens": { + "$ref": "#/components/schemas/TokensOut" + } + }, + "type": "object", + "required": [ + "user", + "tokens" + ], + "title": "AuthOut" + }, + "BenchmarkOut": { + "additionalProperties": false, + "properties": { + "benchmark_id": { + "title": "Benchmark Id", + "type": "string" + }, + "version": { + "title": "Version", + "type": "string" + }, + "population": { + "title": "Population", + "type": "string" + }, + "on_target": { + "$ref": "#/components/schemas/Interval" + }, + "satisfactory": { + "$ref": "#/components/schemas/Interval" + }, + "unit": { + "title": "Unit", + "type": "string" + }, + "source_reference": { + "title": "Source Reference", + "type": "string" + } + }, + "required": [ + "benchmark_id", + "version", + "population", + "on_target", + "satisfactory", + "unit", + "source_reference" + ], + "title": "BenchmarkOut", + "type": "object" + }, + "CapabilitiesOut": { + "properties": { + "player": { + "type": "boolean", + "title": "Player" + }, + "coach": { + "type": "boolean", + "title": "Coach" + }, + "academy_admin": { + "type": "boolean", + "title": "Academy Admin" + }, + "corporate_view": { + "type": "boolean", + "title": "Corporate View" + } + }, + "type": "object", + "required": [ + "player", + "coach", + "academy_admin", + "corporate_view" + ], + "title": "CapabilitiesOut" + }, + "Cards": { + "properties": { + "g": { + "type": "integer", + "title": "G" + }, + "y": { + "type": "integer", + "title": "Y" + }, + "r": { + "type": "integer", + "title": "R" + } + }, + "type": "object", + "required": [ + "g", + "y", + "r" + ], + "title": "Cards" + }, + "CatalogOut": { + "properties": { + "groups": { + "items": { + "$ref": "#/components/schemas/app__modules__catalog__schemas__GroupOut" + }, + "type": "array", + "title": "Groups" + }, + "metrics": { + "items": { + "$ref": "#/components/schemas/MetricOut" + }, + "type": "array", + "title": "Metrics" + }, + "drills": { + "items": { + "$ref": "#/components/schemas/DrillOut" + }, + "type": "array", + "title": "Drills" + } + }, + "type": "object", + "required": [ + "groups", + "metrics", + "drills" + ], + "title": "CatalogOut" + }, + "CoachAccessBody": { + "properties": { + "coach_access": { + "$ref": "#/components/schemas/CoachAccessOut" + } + }, + "type": "object", + "required": [ + "coach_access" + ], + "title": "CoachAccessBody" + }, + "CoachAccessCreate": { + "properties": { + "code": { + "type": "string", + "maxLength": 64, + "minLength": 6, + "title": "Code" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "code" + ], + "title": "CoachAccessCreate" + }, + "CoachAccessOut": { + "properties": { + "status": { + "type": "string", + "enum": [ + "none", + "pending", + "approved", + "declined" + ], + "title": "Status" + }, + "code": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Code" + }, + "sent_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Sent At" + } + }, + "type": "object", + "required": [ + "status", + "code", + "sent_at" + ], + "title": "CoachAccessOut" + }, + "CoachActivity": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "coaches": { + "type": "string", + "title": "Coaches" + }, + "reviews": { + "type": "integer", + "title": "Reviews" + } + }, + "type": "object", + "required": [ + "id", + "name", + "coaches", + "reviews" + ], + "title": "CoachActivity" + }, + "CoachBody": { + "properties": { + "coach": { + "$ref": "#/components/schemas/CoachOut" + } + }, + "type": "object", + "required": [ + "coach" + ], + "title": "CoachBody" + }, + "CoachOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "coaches": { + "type": "string", + "title": "Coaches" + }, + "joined": { + "type": "string", + "format": "date-time", + "title": "Joined" + }, + "joined_with": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Joined With" + }, + "role": { + "type": "string", + "enum": [ + "admin", + "coach", + "assistant" + ], + "title": "Role" + }, + "is_me": { + "type": "boolean", + "title": "Is Me" + }, + "sees_all": { + "type": "boolean", + "title": "Sees All" + }, + "group_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Group Ids" + }, + "permissions": { + "anyOf": [ + { + "additionalProperties": { + "type": "boolean" + }, + "type": "object" + }, + { + "type": "null" + } + ], + "title": "Permissions" + }, + "activity": { + "anyOf": [ + { + "$ref": "#/components/schemas/ActivityOut" + }, + { + "type": "null" + } + ] + }, + "status": { + "type": "string", + "enum": [ + "active", + "paused", + "removed" + ], + "title": "Status" + }, + "version": { + "type": "integer", + "title": "Version" + } + }, + "type": "object", + "required": [ + "id", + "name", + "coaches", + "joined", + "joined_with", + "role", + "is_me", + "sees_all", + "group_ids", + "permissions", + "activity", + "status", + "version" + ], + "title": "CoachOut" + }, + "CoachUpdate": { + "properties": { + "role": { + "anyOf": [ + { + "type": "string", + "enum": [ + "admin", + "coach", + "assistant" + ] + }, + { + "type": "null" + } + ], + "title": "Role" + }, + "sees_all": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Sees All" + }, + "group_ids": { + "anyOf": [ + { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array" + }, + { + "type": "null" + } + ], + "title": "Group Ids" + }, + "permissions": { + "anyOf": [ + { + "$ref": "#/components/schemas/PermissionsIn" + }, + { + "type": "null" + } + ] + }, + "status": { + "anyOf": [ + { + "type": "string", + "enum": [ + "active", + "paused" + ] + }, + { + "type": "null" + } + ], + "title": "Status" + }, + "expected_version": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Expected Version" + } + }, + "additionalProperties": false, + "type": "object", + "title": "CoachUpdate" + }, + "ConsentExportRequest": { + "properties": { + "format": { + "type": "string", + "const": "csv", + "title": "Format", + "default": "csv" + }, + "group_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Group Id" + } + }, + "additionalProperties": false, + "type": "object", + "title": "ConsentExportRequest" + }, + "ConsentIn": { + "properties": { + "version": { + "type": "string", + "maxLength": 16, + "minLength": 1, + "title": "Version" + }, + "accepted": { + "type": "boolean", + "const": true, + "title": "Accepted" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "version", + "accepted" + ], + "title": "ConsentIn" + }, + "ConsentItem": { + "properties": { + "player_id": { + "type": "string", + "format": "uuid", + "title": "Player Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "group": { + "type": "string", + "title": "Group" + }, + "group_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Group Ids" + }, + "note": { + "type": "string", + "title": "Note" + }, + "version": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Version" + }, + "accepted_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Accepted At" + }, + "withdrawn_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Withdrawn At" + }, + "help_improve_ai": { + "type": "boolean", + "title": "Help Improve Ai" + } + }, + "type": "object", + "required": [ + "player_id", + "name", + "group", + "group_ids", + "note", + "version", + "accepted_at", + "withdrawn_at", + "help_improve_ai" + ], + "title": "ConsentItem" + }, + "ConsentPage": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/ConsentItem" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + }, + "accepted": { + "type": "integer", + "title": "Accepted" + }, + "ai_opt_in": { + "type": "integer", + "title": "Ai Opt In" + } + }, + "type": "object", + "required": [ + "items", + "accepted", + "ai_opt_in" + ], + "title": "ConsentPage" + }, + "CorpFix": { + "properties": { + "metric_id": { + "type": "string", + "title": "Metric Id" + }, + "label": { + "type": "string", + "title": "Label" + }, + "mode": { + "type": "string", + "enum": [ + "h", + "p" + ], + "title": "Mode" + }, + "affected_pct": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Affected Pct" + } + }, + "type": "object", + "required": [ + "metric_id", + "label", + "mode", + "affected_pct" + ], + "title": "CorpFix" + }, + "CorpKpis": { + "properties": { + "locations_live": { + "type": "integer", + "title": "Locations Live" + }, + "active_players": { + "type": "integer", + "title": "Active Players" + }, + "analyses": { + "type": "integer", + "title": "Analyses" + }, + "improving_pct": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Improving Pct" + } + }, + "type": "object", + "required": [ + "locations_live", + "active_players", + "analyses", + "improving_pct" + ], + "title": "CorpKpis" + }, + "CorpLocation": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "active_players": { + "type": "integer", + "title": "Active Players" + }, + "improving_pct": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Improving Pct" + } + }, + "type": "object", + "required": [ + "id", + "name", + "active_players", + "improving_pct" + ], + "title": "CorpLocation" + }, + "Corporate": { + "properties": { + "month": { + "type": "string", + "title": "Month" + }, + "as_of": { + "type": "string", + "format": "date-time", + "title": "As Of" + }, + "kpis": { + "$ref": "#/components/schemas/CorpKpis" + }, + "locations": { + "items": { + "$ref": "#/components/schemas/CorpLocation" + }, + "type": "array", + "title": "Locations" + }, + "fixes": { + "items": { + "$ref": "#/components/schemas/CorpFix" + }, + "type": "array", + "title": "Fixes" + } + }, + "type": "object", + "required": [ + "month", + "as_of", + "kpis", + "locations", + "fixes" + ], + "title": "Corporate" + }, + "CorporateResponse": { + "properties": { + "corporate": { + "$ref": "#/components/schemas/Corporate" + } + }, + "type": "object", + "required": [ + "corporate" + ], + "title": "CorporateResponse" + }, + "Dashboard": { + "properties": { + "month": { + "type": "string", + "title": "Month" + }, + "currency": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Currency" + }, + "earnings_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Earnings Minor" + }, + "paying_players": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Paying Players" + }, + "per_player_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Per Player Minor" + }, + "active_players": { + "type": "integer", + "title": "Active Players" + }, + "new_this_month": { + "type": "integer", + "title": "New This Month" + }, + "improving_pct": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Improving Pct" + }, + "analyses_this_week": { + "type": "integer", + "title": "Analyses This Week" + }, + "avg_review_hours": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Avg Review Hours" + }, + "cards": { + "$ref": "#/components/schemas/Cards" + }, + "coaches": { + "items": { + "$ref": "#/components/schemas/CoachActivity" + }, + "type": "array", + "title": "Coaches" + }, + "pending_requests": { + "type": "integer", + "title": "Pending Requests" + }, + "not_filmed_7d": { + "type": "integer", + "title": "Not Filmed 7D" + }, + "earnings_bars": { + "items": { + "$ref": "#/components/schemas/EarningsBar" + }, + "type": "array", + "title": "Earnings Bars", + "default": [] + }, + "unavailable_reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Unavailable Reason" + }, + "as_of": { + "type": "string", + "format": "date-time", + "title": "As Of" + } + }, + "type": "object", + "required": [ + "month", + "active_players", + "new_this_month", + "improving_pct", + "analyses_this_week", + "avg_review_hours", + "cards", + "coaches", + "pending_requests", + "not_filmed_7d", + "as_of" + ], + "title": "Dashboard" + }, + "DashboardResponse": { + "properties": { + "dashboard": { + "$ref": "#/components/schemas/Dashboard" + } + }, + "type": "object", + "required": [ + "dashboard" + ], + "title": "DashboardResponse" + }, + "DataQualityNote": { + "additionalProperties": false, + "properties": { + "code": { + "title": "Code", + "type": "string" + }, + "severity": { + "enum": [ + "info", + "warning" + ], + "title": "Severity", + "type": "string" + }, + "text": { + "title": "Text", + "type": "string" + } + }, + "required": [ + "code", + "severity", + "text" + ], + "title": "DataQualityNote", + "type": "object" + }, + "DecisionIn": { + "properties": { + "decision": { + "type": "string", + "enum": [ + "approve", + "decline" + ], + "title": "Decision" + }, + "role": { + "anyOf": [ + { + "type": "string", + "enum": [ + "coach", + "assistant" + ] + }, + { + "type": "null" + } + ], + "title": "Role" + }, + "sees_all": { + "type": "boolean", + "title": "Sees All", + "default": false + }, + "group_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Group Ids" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "decision" + ], + "title": "DecisionIn" + }, + "DecisionOut": { + "properties": { + "request": { + "$ref": "#/components/schemas/RequestOut" + }, + "coach": { + "anyOf": [ + { + "$ref": "#/components/schemas/CoachOut" + }, + { + "type": "null" + } + ] + } + }, + "type": "object", + "required": [ + "request", + "coach" + ], + "title": "DecisionOut" + }, + "DeviceCreate": { + "properties": { + "platform": { + "type": "string", + "enum": [ + "ios", + "android" + ], + "title": "Platform" + }, + "push_token": { + "type": "string", + "maxLength": 4096, + "minLength": 1, + "title": "Push Token" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "platform", + "push_token" + ], + "title": "DeviceCreate" + }, + "DeviceOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "platform": { + "type": "string", + "title": "Platform" + }, + "push_token": { + "type": "string", + "title": "Push Token" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + } + }, + "type": "object", + "required": [ + "id", + "platform", + "push_token", + "created_at" + ], + "title": "DeviceOut" + }, + "DeviceResponse": { + "properties": { + "device": { + "$ref": "#/components/schemas/DeviceOut" + } + }, + "type": "object", + "required": [ + "device" + ], + "title": "DeviceResponse" + }, + "Drill": { + "additionalProperties": false, + "properties": { + "drill_id": { + "title": "Drill Id", + "type": "string" + }, + "name": { + "title": "Name", + "type": "string" + }, + "how": { + "title": "How", + "type": "string" + }, + "cue": { + "title": "Cue", + "type": "string" + }, + "reps": { + "title": "Reps", + "type": "string" + } + }, + "required": [ + "drill_id", + "name", + "how", + "cue", + "reps" + ], + "title": "Drill", + "type": "object" + }, + "DrillLogEnvelope": { + "properties": { + "log": { + "$ref": "#/components/schemas/DrillLogOut" + } + }, + "type": "object", + "required": [ + "log" + ], + "title": "DrillLogEnvelope" + }, + "DrillLogIn": { + "properties": { + "session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Session Id" + }, + "drill_id": { + "type": "string", + "maxLength": 16, + "minLength": 1, + "title": "Drill Id" + }, + "reps": { + "type": "integer", + "maximum": 8.0, + "minimum": 1.0, + "title": "Reps" + }, + "day": { + "type": "string", + "format": "date", + "title": "Day" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "drill_id", + "reps", + "day" + ], + "title": "DrillLogIn" + }, + "DrillLogOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Session Id" + }, + "drill_id": { + "type": "string", + "title": "Drill Id" + }, + "assignment_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Assignment Id" + }, + "reps": { + "type": "integer", + "title": "Reps" + }, + "day": { + "type": "string", + "format": "date", + "title": "Day" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + } + }, + "type": "object", + "required": [ + "id", + "session_id", + "drill_id", + "assignment_id", + "reps", + "day", + "created_at" + ], + "title": "DrillLogOut" + }, + "DrillOut": { + "properties": { + "drill_id": { + "type": "string", + "title": "Drill Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "how": { + "type": "string", + "title": "How" + }, + "cue": { + "type": "string", + "title": "Cue" + }, + "reps": { + "type": "string", + "title": "Reps" + } + }, + "type": "object", + "required": [ + "drill_id", + "name", + "how", + "cue", + "reps" + ], + "title": "DrillOut" + }, + "Earnings": { + "properties": { + "month": { + "type": "string", + "title": "Month" + }, + "currency": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Currency" + }, + "month_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Month Minor" + }, + "players": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Players" + }, + "per_player_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Per Player Minor" + }, + "ytd_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Ytd Minor" + }, + "projected_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Projected Minor" + }, + "as_of": { + "type": "string", + "format": "date-time", + "title": "As Of" + }, + "payouts": { + "items": { + "$ref": "#/components/schemas/Payout" + }, + "type": "array", + "title": "Payouts", + "default": [] + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + }, + "unavailable_reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Unavailable Reason" + } + }, + "type": "object", + "required": [ + "month", + "as_of" + ], + "title": "Earnings" + }, + "EarningsBar": { + "properties": { + "month": { + "type": "string", + "title": "Month" + }, + "amount_minor": { + "type": "integer", + "title": "Amount Minor" + } + }, + "type": "object", + "required": [ + "month", + "amount_minor" + ], + "title": "EarningsBar" + }, + "EarningsResponse": { + "properties": { + "earnings": { + "$ref": "#/components/schemas/Earnings" + } + }, + "type": "object", + "required": [ + "earnings" + ], + "title": "EarningsResponse" + }, + "EnsureThreadIn": { + "properties": { + "mode": { + "type": "string", + "enum": [ + "h", + "p" + ], + "title": "Mode" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "mode" + ], + "title": "EnsureThreadIn" + }, + "Entitlement": { + "properties": { + "plan": { + "type": "string", + "title": "Plan" + }, + "weekly_limit": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Weekly Limit" + }, + "used_this_week": { + "type": "integer", + "title": "Used This Week" + }, + "left": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Left" + }, + "window_days": { + "type": "integer", + "title": "Window Days" + } + }, + "type": "object", + "required": [ + "plan", + "weekly_limit", + "used_this_week", + "left", + "window_days" + ], + "title": "Entitlement" + }, + "ExportEnvelope": { + "properties": { + "export": { + "$ref": "#/components/schemas/app__modules__settings__schemas__ExportOut" + } + }, + "type": "object", + "required": [ + "export" + ], + "title": "ExportEnvelope" + }, + "ExportIn": { + "properties": { + "scope": { + "type": "string", + "const": "videos", + "title": "Scope" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "scope" + ], + "title": "ExportIn" + }, + "ExportResponse": { + "properties": { + "export": { + "$ref": "#/components/schemas/app__modules__reporting__schemas__ExportOut" + } + }, + "type": "object", + "required": [ + "export" + ], + "title": "ExportResponse" + }, + "FeelIn": { + "properties": { + "feel": { + "type": "string", + "enum": [ + "sore", + "tight", + "good" + ], + "title": "Feel" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "feel" + ], + "title": "FeelIn" + }, + "FeelOut": { + "properties": { + "feel": { + "type": "string", + "title": "Feel" + }, + "recorded_at": { + "type": "string", + "format": "date-time", + "title": "Recorded At" + } + }, + "type": "object", + "required": [ + "feel", + "recorded_at" + ], + "title": "FeelOut" + }, + "Finding": { + "properties": { + "metric_id": { + "type": "string", + "title": "Metric Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "verdict": { + "type": "string", + "enum": [ + "agree", + "change", + "later" + ], + "title": "Verdict" + } + }, + "type": "object", + "required": [ + "metric_id", + "name", + "verdict" + ], + "title": "Finding" + }, + "FocusArea": { + "additionalProperties": false, + "properties": { + "kind": { + "enum": [ + "fix", + "maintain", + "general" + ], + "title": "Kind", + "type": "string" + }, + "is_tentative": { + "title": "Is Tentative", + "type": "boolean" + }, + "metric_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Metric Id" + }, + "group": { + "anyOf": [ + { + "enum": [ + "balance_load", + "stride", + "power_move", + "contact_follow_through" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Group" + }, + "display_name": { + "title": "Display Name", + "type": "string" + }, + "rating": { + "enum": [ + "on_target", + "satisfactory", + "off_target", + "not_rated" + ], + "title": "Rating", + "type": "string" + }, + "rating_label": { + "title": "Rating Label", + "type": "string" + }, + "coach_message": { + "title": "Coach Message", + "type": "string" + }, + "practice_feel": { + "title": "Practice Feel", + "type": "string" + }, + "drill": { + "$ref": "#/components/schemas/Drill" + }, + "evidence_metric_ids": { + "items": { + "type": "string" + }, + "title": "Evidence Metric Ids", + "type": "array" + } + }, + "required": [ + "kind", + "is_tentative", + "metric_id", + "group", + "display_name", + "rating", + "rating_label", + "coach_message", + "practice_feel", + "drill", + "evidence_metric_ids" + ], + "title": "FocusArea", + "type": "object" + }, + "FocusSummary": { + "properties": { + "metric_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Metric Id" + }, + "display_name": { + "type": "string", + "title": "Display Name" + }, + "drill_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Drill Id" + } + }, + "type": "object", + "required": [ + "metric_id", + "display_name", + "drill_id" + ], + "title": "FocusSummary" + }, + "ForgotPasswordIn": { + "properties": { + "email": { + "type": "string", + "maxLength": 254, + "title": "Email" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "email" + ], + "title": "ForgotPasswordIn" + }, + "GoalEnvelope": { + "properties": { + "goal": { + "anyOf": [ + { + "$ref": "#/components/schemas/GoalOut" + }, + { + "type": "null" + } + ] + } + }, + "type": "object", + "required": [ + "goal" + ], + "title": "GoalEnvelope" + }, + "GoalHistoryOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "text": { + "type": "string", + "title": "Text" + }, + "range": { + "type": "string", + "title": "Range" + }, + "met": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Met" + }, + "outcome": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Outcome" + }, + "start_at": { + "type": "string", + "format": "date-time", + "title": "Start At" + }, + "end_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "End At" + }, + "evaluated_session_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Evaluated Session Id" + } + }, + "type": "object", + "required": [ + "id", + "text", + "range", + "met", + "outcome", + "start_at", + "end_at", + "evaluated_session_id" + ], + "title": "GoalHistoryOut" + }, + "GoalIn": { + "properties": { + "type": { + "type": "string", + "enum": [ + "groups", + "param", + "score" + ], + "title": "Type" + }, + "target": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "number" + } + ], + "title": "Target" + }, + "metric_id": { + "anyOf": [ + { + "type": "string", + "maxLength": 64 + }, + { + "type": "null" + } + ], + "title": "Metric Id" + }, + "due": { + "type": "string", + "enum": [ + "1 week", + "2 weeks", + "End of month" + ], + "title": "Due" + }, + "weekly": { + "$ref": "#/components/schemas/WeeklyIn" + }, + "note": { + "type": "string", + "maxLength": 160, + "title": "Note", + "default": "" + }, + "expected_version": { + "anyOf": [ + { + "type": "integer", + "minimum": 0.0 + }, + { + "type": "null" + } + ], + "title": "Expected Version" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "type", + "target", + "due", + "weekly" + ], + "title": "GoalIn" + }, + "GoalOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "player_id": { + "type": "string", + "format": "uuid", + "title": "Player Id" + }, + "mode": { + "type": "string", + "title": "Mode" + }, + "type": { + "type": "string", + "title": "Type" + }, + "target": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "number" + } + ], + "title": "Target" + }, + "metric_id": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Metric Id" + }, + "metric_name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Metric Name" + }, + "due": { + "type": "string", + "title": "Due" + }, + "due_at": { + "type": "string", + "format": "date-time", + "title": "Due At" + }, + "set_at": { + "type": "string", + "format": "date-time", + "title": "Set At" + }, + "set_by": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Set By" + }, + "set_by_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Set By Id" + }, + "note": { + "type": "string", + "title": "Note" + }, + "weekly": { + "$ref": "#/components/schemas/WeeklyOut" + }, + "version": { + "type": "integer", + "title": "Version" + } + }, + "type": "object", + "required": [ + "id", + "player_id", + "mode", + "type", + "target", + "metric_id", + "metric_name", + "due", + "due_at", + "set_at", + "set_by", + "set_by_id", + "note", + "weekly", + "version" + ], + "title": "GoalOut" + }, + "GroupEnvelope": { + "properties": { + "group": { + "$ref": "#/components/schemas/app__modules__academy_org__schemas__GroupOut" + } + }, + "type": "object", + "required": [ + "group" + ], + "title": "GroupEnvelope" + }, + "GroupIn": { + "properties": { + "name": { + "type": "string", + "maxLength": 80, + "minLength": 1, + "title": "Name" + }, + "focus": { + "type": "string", + "enum": [ + "Hitting", + "Pitching", + "Both" + ], + "title": "Focus" + }, + "coach_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "maxItems": 200, + "title": "Coach Ids" + }, + "player_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "maxItems": 1000, + "title": "Player Ids" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "focus" + ], + "title": "GroupIn" + }, + "GroupReport": { + "additionalProperties": false, + "properties": { + "group": { + "enum": [ + "balance_load", + "stride", + "power_move", + "contact_follow_through" + ], + "title": "Group", + "type": "string" + }, + "display_name": { + "title": "Display Name", + "type": "string" + }, + "score": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Score" + }, + "score_is_tentative": { + "title": "Score Is Tentative", + "type": "boolean" + }, + "rating": { + "enum": [ + "on_target", + "satisfactory", + "off_target", + "not_rated" + ], + "title": "Rating", + "type": "string" + }, + "rating_label": { + "title": "Rating Label", + "type": "string" + }, + "not_rated_reason": { + "anyOf": [ + { + "enum": [ + "measurement_unavailable", + "no_benchmark", + "no_measurements_available", + "measurements_unavailable", + "no_rated_measurements" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Not Rated Reason" + }, + "summary": { + "title": "Summary", + "type": "string" + }, + "metric_ids": { + "items": { + "type": "string" + }, + "title": "Metric Ids", + "type": "array" + } + }, + "required": [ + "group", + "display_name", + "score", + "score_is_tentative", + "rating", + "rating_label", + "not_rated_reason", + "summary", + "metric_ids" + ], + "title": "GroupReport", + "type": "object" + }, + "Interval": { + "additionalProperties": false, + "properties": { + "lower": { + "title": "Lower", + "type": "number" + }, + "upper": { + "title": "Upper", + "type": "number" + } + }, + "required": [ + "lower", + "upper" + ], + "title": "Interval", + "type": "object" + }, + "Items_DrillLogOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/DrillLogOut" + }, + "type": "array", + "title": "Items" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Items[DrillLogOut]" + }, + "Items_RosterItem_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/RosterItem" + }, + "type": "array", + "title": "Items" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Items[RosterItem]" + }, + "LastByMode": { + "properties": { + "h": { + "anyOf": [ + { + "$ref": "#/components/schemas/LastSession" + }, + { + "type": "null" + } + ] + }, + "p": { + "anyOf": [ + { + "$ref": "#/components/schemas/LastSession" + }, + { + "type": "null" + } + ] + } + }, + "type": "object", + "title": "LastByMode" + }, + "LastSession": { + "properties": { + "session_id": { + "type": "string", + "format": "uuid", + "title": "Session Id" + }, + "overall_score": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Overall Score" + }, + "delta": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Delta" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + }, + "focus_name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Focus Name" + } + }, + "type": "object", + "required": [ + "session_id", + "overall_score", + "delta", + "created_at", + "focus_name" + ], + "title": "LastSession" + }, + "LibraryDrillIn": { + "properties": { + "upload_id": { + "type": "string", + "format": "uuid", + "title": "Upload Id" + }, + "name": { + "type": "string", + "maxLength": 120, + "minLength": 1, + "title": "Name" + }, + "mode": { + "type": "string", + "enum": [ + "h", + "p" + ], + "title": "Mode" + }, + "fault_tags": { + "items": { + "type": "string", + "maxLength": 64, + "minLength": 1 + }, + "type": "array", + "maxItems": 10, + "minItems": 1, + "title": "Fault Tags" + }, + "fixes": { + "type": "string", + "maxLength": 500, + "title": "Fixes", + "default": "" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "upload_id", + "name", + "mode", + "fault_tags" + ], + "title": "LibraryDrillIn" + }, + "LibraryDrillOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "fixes": { + "type": "string", + "title": "Fixes" + }, + "fault_tags": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Fault Tags" + }, + "by": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "By" + }, + "author_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Author Id" + }, + "mode": { + "type": "string", + "enum": [ + "h", + "p" + ], + "title": "Mode" + }, + "media": { + "anyOf": [ + { + "$ref": "#/components/schemas/MediaRef" + }, + { + "type": "null" + } + ] + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + } + }, + "type": "object", + "required": [ + "id", + "name", + "fixes", + "fault_tags", + "by", + "author_id", + "mode", + "media", + "created_at" + ], + "title": "LibraryDrillOut" + }, + "LibraryEnvelope": { + "properties": { + "drill": { + "$ref": "#/components/schemas/LibraryDrillOut" + } + }, + "type": "object", + "required": [ + "drill" + ], + "title": "LibraryEnvelope" + }, + "Limitation": { + "additionalProperties": false, + "properties": { + "code": { + "title": "Code", + "type": "string" + }, + "text": { + "title": "Text", + "type": "string" + } + }, + "required": [ + "code", + "text" + ], + "title": "Limitation", + "type": "object" + }, + "LoginIn": { + "properties": { + "email": { + "type": "string", + "maxLength": 254, + "minLength": 1, + "title": "Email" + }, + "password": { + "type": "string", + "maxLength": 128, + "minLength": 1, + "title": "Password" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "email", + "password" + ], + "title": "LoginIn" + }, + "MarksIn": { + "properties": { + "contact_frame": { + "type": "integer", + "minimum": 0.0, + "title": "Contact Frame" + }, + "contact_offset": { + "type": "integer", + "title": "Contact Offset" + }, + "contact_source": { + "type": "string", + "enum": [ + "detected", + "suggested", + "manual" + ], + "title": "Contact Source" + }, + "stride_start_frame": { + "type": "integer", + "minimum": 0.0, + "title": "Stride Start Frame" + }, + "stride_end_frame": { + "type": "integer", + "minimum": 0.0, + "title": "Stride End Frame" + }, + "pitcher_direction": { + "anyOf": [ + { + "$ref": "#/components/schemas/PitcherDirection" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "contact_frame", + "contact_offset", + "contact_source", + "stride_start_frame", + "stride_end_frame" + ], + "title": "MarksIn" + }, + "MeOut": { + "properties": { + "user": { + "$ref": "#/components/schemas/UserOut" + }, + "team": { + "anyOf": [ + { + "$ref": "#/components/schemas/TeamOut" + }, + { + "type": "null" + } + ] + }, + "entitlement": { + "$ref": "#/components/schemas/Entitlement" + }, + "academy": { + "anyOf": [ + { + "$ref": "#/components/schemas/AcademyOut" + }, + { + "type": "null" + } + ] + }, + "coach_access": { + "$ref": "#/components/schemas/CoachAccessOut" + }, + "capabilities": { + "$ref": "#/components/schemas/CapabilitiesOut" + } + }, + "type": "object", + "required": [ + "user", + "team", + "entitlement", + "coach_access", + "capabilities" + ], + "title": "MeOut" + }, + "MeUpdate": { + "properties": { + "role": { + "anyOf": [ + { + "type": "string", + "enum": [ + "player", + "coach" + ] + }, + { + "type": "null" + } + ], + "title": "Role" + }, + "focus": { + "anyOf": [ + { + "type": "string", + "enum": [ + "h", + "p", + "both" + ] + }, + { + "type": "null" + } + ], + "title": "Focus" + }, + "unit": { + "anyOf": [ + { + "type": "string", + "enum": [ + "imperial", + "metric" + ] + }, + { + "type": "null" + } + ], + "title": "Unit" + }, + "private_videos": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Private Videos" + }, + "profile": { + "anyOf": [ + { + "$ref": "#/components/schemas/ProfileUpdate" + }, + { + "type": "null" + } + ] + } + }, + "additionalProperties": false, + "type": "object", + "title": "MeUpdate", + "description": "Partial update: only the fields sent are changed. Profile nulls clear a value; top-level nulls are rejected." + }, + "MeasurementReport": { + "additionalProperties": false, + "properties": { + "metric_id": { + "title": "Metric Id", + "type": "string" + }, + "display_name": { + "title": "Display Name", + "type": "string" + }, + "group": { + "enum": [ + "balance_load", + "stride", + "power_move", + "contact_follow_through" + ], + "title": "Group", + "type": "string" + }, + "status": { + "enum": [ + "available", + "limited", + "unavailable" + ], + "title": "Status", + "type": "string" + }, + "value": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Value" + }, + "unit": { + "title": "Unit", + "type": "string" + }, + "display_value": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Display Value" + }, + "score": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Score" + }, + "rating": { + "enum": [ + "on_target", + "satisfactory", + "off_target", + "not_rated" + ], + "title": "Rating", + "type": "string" + }, + "rating_label": { + "title": "Rating Label", + "type": "string" + }, + "rating_is_tentative": { + "title": "Rating Is Tentative", + "type": "boolean" + }, + "not_rated_reason": { + "anyOf": [ + { + "enum": [ + "measurement_unavailable", + "no_benchmark", + "no_measurements_available", + "measurements_unavailable", + "no_rated_measurements" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Not Rated Reason" + }, + "benchmark": { + "anyOf": [ + { + "$ref": "#/components/schemas/BenchmarkOut" + }, + { + "type": "null" + } + ] + }, + "what_it_means": { + "title": "What It Means", + "type": "string" + }, + "result_text": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Result Text" + }, + "coach_tip": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Coach Tip" + }, + "limitations": { + "items": { + "$ref": "#/components/schemas/Limitation" + }, + "title": "Limitations", + "type": "array" + } + }, + "required": [ + "metric_id", + "display_name", + "group", + "status", + "value", + "unit", + "display_value", + "score", + "rating", + "rating_label", + "rating_is_tentative", + "not_rated_reason", + "benchmark", + "what_it_means", + "result_text", + "coach_tip", + "limitations" + ], + "title": "MeasurementReport", + "type": "object" + }, + "MediaOut": { + "properties": { + "video_url": { + "type": "string", + "title": "Video Url" + }, + "thumbnail_url": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Thumbnail Url" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "title": "Expires At" + } + }, + "type": "object", + "required": [ + "video_url", + "thumbnail_url", + "expires_at" + ], + "title": "MediaOut" + }, + "MediaRef": { + "properties": { + "upload_id": { + "type": "string", + "format": "uuid", + "title": "Upload Id" + }, + "url": { + "type": "string", + "title": "Url" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "title": "Expires At" + }, + "seconds": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Seconds" + } + }, + "type": "object", + "required": [ + "upload_id", + "url", + "expires_at" + ], + "title": "MediaRef", + "description": "A short-lived authorised read URL for stored media. Refetch the owning resource when it expires." + }, + "MemberOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "focus": { + "type": "string", + "title": "Focus" + }, + "level": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Level" + }, + "group_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Group Ids" + } + }, + "type": "object", + "required": [ + "id", + "name", + "focus", + "level", + "group_ids" + ], + "title": "MemberOut" + }, + "MetricOut": { + "properties": { + "metric_id": { + "type": "string", + "title": "Metric Id" + }, + "display_name": { + "type": "string", + "title": "Display Name" + }, + "group": { + "type": "string", + "title": "Group" + }, + "unit": { + "type": "string", + "title": "Unit" + }, + "what_it_means": { + "type": "string", + "title": "What It Means" + } + }, + "type": "object", + "required": [ + "metric_id", + "display_name", + "group", + "unit", + "what_it_means" + ], + "title": "MetricOut" + }, + "MilestoneOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "icon": { + "type": "string", + "title": "Icon" + }, + "tone": { + "type": "string", + "title": "Tone" + }, + "title": { + "type": "string", + "title": "Title" + }, + "when": { + "type": "string", + "title": "When" + }, + "occurred_at": { + "type": "string", + "format": "date-time", + "title": "Occurred At" + }, + "source_goal_id": { + "type": "string", + "format": "uuid", + "title": "Source Goal Id" + } + }, + "type": "object", + "required": [ + "id", + "icon", + "tone", + "title", + "when", + "occurred_at", + "source_goal_id" + ], + "title": "MilestoneOut" + }, + "NoteEnvelope": { + "properties": { + "note": { + "$ref": "#/components/schemas/NoteOut" + } + }, + "type": "object", + "required": [ + "note" + ], + "title": "NoteEnvelope" + }, + "NoteIn": { + "properties": { + "text": { + "type": "string", + "maxLength": 4000, + "title": "Text" + }, + "expected_version": { + "anyOf": [ + { + "type": "integer", + "minimum": 0.0 + }, + { + "type": "null" + } + ], + "title": "Expected Version" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "text" + ], + "title": "NoteIn" + }, + "NoteOut": { + "properties": { + "player_id": { + "type": "string", + "format": "uuid", + "title": "Player Id" + }, + "text": { + "type": "string", + "title": "Text" + }, + "updated_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Updated At" + }, + "version": { + "type": "integer", + "title": "Version" + } + }, + "type": "object", + "required": [ + "player_id", + "text", + "updated_at", + "version" + ], + "title": "NoteOut" + }, + "NotificationOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "kind": { + "type": "string", + "title": "Kind" + }, + "title": { + "type": "string", + "title": "Title" + }, + "body": { + "type": "string", + "title": "Body" + }, + "at": { + "type": "string", + "format": "date-time", + "title": "At" + }, + "read": { + "type": "boolean", + "title": "Read" + }, + "target": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Target" + } + }, + "type": "object", + "required": [ + "id", + "kind", + "title", + "body", + "at", + "read", + "target" + ], + "title": "NotificationOut" + }, + "OutingIn": { + "properties": { + "pitches": { + "type": "integer", + "maximum": 200.0, + "minimum": 1.0, + "title": "Pitches" + }, + "local_date": { + "anyOf": [ + { + "type": "string", + "format": "date" + }, + { + "type": "null" + } + ], + "title": "Local Date" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "pitches" + ], + "title": "OutingIn" + }, + "OutingOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "date": { + "type": "string", + "format": "date-time", + "title": "Date" + }, + "local_date": { + "type": "string", + "format": "date", + "title": "Local Date" + }, + "label": { + "type": "string", + "title": "Label" + }, + "pitches": { + "type": "integer", + "title": "Pitches" + }, + "rest": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Rest" + }, + "rest_days": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Rest Days" + } + }, + "type": "object", + "required": [ + "id", + "date", + "local_date", + "label", + "pitches" + ], + "title": "OutingOut" + }, + "OutingResult": { + "properties": { + "outing": { + "$ref": "#/components/schemas/OutingOut" + }, + "arm_care": { + "$ref": "#/components/schemas/ArmCareOut" + } + }, + "type": "object", + "required": [ + "outing", + "arm_care" + ], + "title": "OutingResult" + }, + "Overview": { + "additionalProperties": false, + "properties": { + "headline": { + "title": "Headline", + "type": "string" + } + }, + "required": [ + "headline" + ], + "title": "Overview", + "type": "object" + }, + "Page_AssignmentOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/AssignmentOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[AssignmentOut]" + }, + "Page_AuditLogSummary_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/AuditLogSummary" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[AuditLogSummary]" + }, + "Page_CoachOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/CoachOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[CoachOut]" + }, + "Page_GoalHistoryOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/GoalHistoryOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[GoalHistoryOut]" + }, + "Page_GroupOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/app__modules__academy_org__schemas__GroupOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[GroupOut]" + }, + "Page_LibraryDrillOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/LibraryDrillOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[LibraryDrillOut]" + }, + "Page_MemberOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/MemberOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[MemberOut]" + }, + "Page_MilestoneOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/MilestoneOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[MilestoneOut]" + }, + "Page_NotificationOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/NotificationOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[NotificationOut]" + }, + "Page_SessionSummary_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/SessionSummary" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[SessionSummary]" + }, + "Page_StaffCodeOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/StaffCodeOut" + }, + "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[StaffCodeOut]" + }, + "Page_ThreadOut_": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/ThreadOut" }, "type": "array", + "title": "Items" + }, + "next_cursor": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Next Cursor" + } + }, + "type": "object", + "required": [ + "items" + ], + "title": "Page[ThreadOut]" + }, + "Payout": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "scheduled_for": { + "type": "string", + "title": "Scheduled For" + }, + "amount_minor": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Amount Minor" + }, + "status": { + "type": "string", + "enum": [ + "scheduled", + "paid", + "failed", + "cancelled" + ], + "title": "Status" + }, + "paid_at": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Paid At" + } + }, + "type": "object", + "required": [ + "id", + "scheduled_for", + "amount_minor", + "status", + "paid_at" + ], + "title": "Payout" + }, + "PermissionsIn": { + "properties": { + "review": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Review" + }, + "drills": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], "title": "Drills" + }, + "goals": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Goals" + }, + "library": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Library" + }, + "earnings": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Earnings" + } + }, + "additionalProperties": false, + "type": "object", + "title": "PermissionsIn" + }, + "PitcherDirection": { + "properties": { + "from": { + "prefixItems": [ + { + "type": "number", + "maximum": 1.0, + "minimum": 0.0 + }, + { + "type": "number", + "maximum": 1.0, + "minimum": 0.0 + } + ], + "type": "array", + "maxItems": 2, + "minItems": 2, + "title": "From" + }, + "to": { + "prefixItems": [ + { + "type": "number", + "maximum": 1.0, + "minimum": 0.0 + }, + { + "type": "number", + "maximum": 1.0, + "minimum": 0.0 + } + ], + "type": "array", + "maxItems": 2, + "minItems": 2, + "title": "To" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "from", + "to" + ], + "title": "PitcherDirection" + }, + "PreviousOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "overall_score": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Overall Score" + }, + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" } }, "type": "object", "required": [ - "groups", - "metrics", - "drills" + "id", + "overall_score", + "created_at" ], - "title": "CatalogOut" + "title": "PreviousOut" }, - "DataQualityNote": { - "additionalProperties": false, + "ProfileOut": { "properties": { - "code": { - "title": "Code", - "type": "string" + "name": { + "type": "string", + "title": "Name" }, - "severity": { - "enum": [ - "info", - "warning" + "age": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } ], - "title": "Severity", - "type": "string" + "title": "Age" }, - "text": { - "title": "Text", - "type": "string" + "height_cm": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Height Cm" + }, + "weight_kg": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Weight Kg" + }, + "bats": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Bats" + }, + "throws": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Throws" + }, + "level": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Level" } }, + "type": "object", "required": [ - "code", - "severity", - "text" + "name", + "age", + "height_cm", + "weight_kg", + "bats", + "throws", + "level" ], - "title": "DataQualityNote", - "type": "object" + "title": "ProfileOut" }, - "DeviceCreate": { + "ProfileUpdate": { "properties": { - "platform": { - "type": "string", - "enum": [ - "ios", - "android" + "name": { + "anyOf": [ + { + "type": "string", + "maxLength": 80 + }, + { + "type": "null" + } ], - "title": "Platform" + "title": "Name" }, - "push_token": { + "age": { + "anyOf": [ + { + "type": "integer", + "maximum": 70.0, + "minimum": 5.0 + }, + { + "type": "null" + } + ], + "title": "Age" + }, + "height_cm": { + "anyOf": [ + { + "type": "number", + "maximum": 230.0, + "minimum": 90.0 + }, + { + "type": "null" + } + ], + "title": "Height Cm" + }, + "weight_kg": { + "anyOf": [ + { + "type": "number", + "maximum": 200.0, + "minimum": 20.0 + }, + { + "type": "null" + } + ], + "title": "Weight Kg" + }, + "bats": { + "anyOf": [ + { + "type": "string", + "enum": [ + "L", + "R", + "S" + ] + }, + { + "type": "null" + } + ], + "title": "Bats" + }, + "throws": { + "anyOf": [ + { + "type": "string", + "enum": [ + "L", + "R" + ] + }, + { + "type": "null" + } + ], + "title": "Throws" + }, + "level": { + "anyOf": [ + { + "type": "string", + "enum": [ + "youth", + "high_school", + "college", + "adult" + ] + }, + { + "type": "null" + } + ], + "title": "Level" + } + }, + "additionalProperties": false, + "type": "object", + "title": "ProfileUpdate" + }, + "PubSubMessage": { + "properties": { + "data": { "type": "string", - "maxLength": 4096, - "minLength": 1, - "title": "Push Token" + "maxLength": 100000, + "title": "Data", + "default": "" + } + }, + "type": "object", + "title": "PubSubMessage" + }, + "PubSubPushIn": { + "properties": { + "message": { + "$ref": "#/components/schemas/PubSubMessage" } }, - "additionalProperties": false, "type": "object", "required": [ - "platform", - "push_token" + "message" ], - "title": "DeviceCreate" + "title": "PubSubPushIn" }, - "DeviceOut": { + "QueueItem": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, - "platform": { + "owner_id": { "type": "string", - "title": "Platform" + "format": "uuid", + "title": "Owner Id" }, - "push_token": { + "mode": { "type": "string", - "title": "Push Token" + "title": "Mode" + }, + "is_self": { + "type": "boolean", + "title": "Is Self" + }, + "athlete_name": { + "type": "string", + "title": "Athlete Name" + }, + "status": { + "type": "string", + "title": "Status" + }, + "overall_score": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Overall Score" + }, + "overall_score_is_tentative": { + "type": "boolean", + "title": "Overall Score Is Tentative" + }, + "focus": { + "anyOf": [ + { + "$ref": "#/components/schemas/FocusSummary" + }, + { + "type": "null" + } + ] + }, + "review": { + "anyOf": [ + { + "$ref": "#/components/schemas/ReviewSummary" + }, + { + "type": "null" + } + ] + }, + "thumbnail_url": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Thumbnail Url" }, "created_at": { "type": "string", "format": "date-time", "title": "Created At" + }, + "owner_name": { + "type": "string", + "title": "Owner Name" } }, "type": "object", "required": [ "id", - "platform", - "push_token", - "created_at" - ], - "title": "DeviceOut" - }, - "DeviceResponse": { - "properties": { - "device": { - "$ref": "#/components/schemas/DeviceOut" - } - }, - "type": "object", - "required": [ - "device" + "owner_id", + "mode", + "is_self", + "athlete_name", + "status", + "overall_score", + "overall_score_is_tentative", + "focus", + "review", + "thumbnail_url", + "created_at", + "owner_name" ], - "title": "DeviceResponse" + "title": "QueueItem" }, - "Drill": { - "additionalProperties": false, + "QueueResponse": { "properties": { - "drill_id": { - "title": "Drill Id", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - }, - "how": { - "title": "How", - "type": "string" - }, - "cue": { - "title": "Cue", - "type": "string" + "open": { + "items": { + "$ref": "#/components/schemas/QueueItem" + }, + "type": "array", + "title": "Open" }, - "reps": { - "title": "Reps", - "type": "string" + "reviewed_today": { + "items": { + "$ref": "#/components/schemas/QueueItem" + }, + "type": "array", + "title": "Reviewed Today" } }, + "type": "object", "required": [ - "drill_id", - "name", - "how", - "cue", - "reps" + "open", + "reviewed_today" ], - "title": "Drill", - "type": "object" + "title": "QueueResponse" }, - "DrillLogEnvelope": { + "ReadAllIn": { "properties": { - "log": { - "$ref": "#/components/schemas/DrillLogOut" + "through": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ], + "title": "Through" } }, + "additionalProperties": false, "type": "object", - "required": [ - "log" - ], - "title": "DrillLogEnvelope" + "title": "ReadAllIn" }, - "DrillLogIn": { + "ReadIn": { "properties": { - "session_id": { + "last_message_id": { "anyOf": [ { "type": "string", @@ -2907,243 +11785,294 @@ "type": "null" } ], - "title": "Session Id" - }, - "drill_id": { - "type": "string", - "maxLength": 16, - "minLength": 1, - "title": "Drill Id" - }, - "reps": { - "type": "integer", - "maximum": 8.0, - "minimum": 1.0, - "title": "Reps" - }, - "day": { - "type": "string", - "format": "date", - "title": "Day" + "title": "Last Message Id" } }, "additionalProperties": false, "type": "object", - "required": [ - "drill_id", - "reps", - "day" - ], - "title": "DrillLogIn" + "title": "ReadIn" }, - "DrillLogOut": { + "ReceiptIn": { "properties": { - "id": { + "platform": { "type": "string", - "format": "uuid", - "title": "Id" + "enum": [ + "ios", + "android" + ], + "title": "Platform" }, - "session_id": { + "product_id": { + "type": "string", + "maxLength": 64, + "minLength": 1, + "title": "Product Id" + }, + "signed_transaction": { "anyOf": [ { "type": "string", - "format": "uuid" + "maxLength": 32000 }, { "type": "null" } ], - "title": "Session Id" - }, - "drill_id": { - "type": "string", - "title": "Drill Id" - }, - "reps": { - "type": "integer", - "title": "Reps" - }, - "day": { - "type": "string", - "format": "date", - "title": "Day" + "title": "Signed Transaction" }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" + "purchase_token": { + "anyOf": [ + { + "type": "string", + "maxLength": 4096 + }, + { + "type": "null" + } + ], + "title": "Purchase Token" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "platform", + "product_id" + ], + "title": "ReceiptIn" + }, + "ReceiptOut": { + "properties": { + "entitlement": { + "$ref": "#/components/schemas/Entitlement" } }, "type": "object", "required": [ - "id", - "session_id", - "drill_id", - "reps", - "day", - "created_at" + "entitlement" ], - "title": "DrillLogOut" + "title": "ReceiptOut" }, - "DrillOut": { + "RecentByMode": { "properties": { - "drill_id": { - "type": "string", - "title": "Drill Id" + "h": { + "items": { + "type": "integer" + }, + "type": "array", + "title": "H", + "default": [] }, - "name": { + "p": { + "items": { + "type": "integer" + }, + "type": "array", + "title": "P", + "default": [] + } + }, + "type": "object", + "title": "RecentByMode" + }, + "RefreshIn": { + "properties": { + "refresh_token": { "type": "string", - "title": "Name" - }, - "how": { + "maxLength": 256, + "minLength": 1, + "title": "Refresh Token" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "refresh_token" + ], + "title": "RefreshIn" + }, + "RegisterIn": { + "properties": { + "email": { "type": "string", - "title": "How" + "maxLength": 254, + "title": "Email" }, - "cue": { + "password": { "type": "string", - "title": "Cue" + "maxLength": 128, + "minLength": 8, + "title": "Password" }, - "reps": { + "role": { "type": "string", - "title": "Reps" + "enum": [ + "player", + "coach" + ], + "title": "Role" } }, + "additionalProperties": false, "type": "object", "required": [ - "drill_id", - "name", - "how", - "cue", - "reps" + "email", + "password", + "role" ], - "title": "DrillOut" + "title": "RegisterIn" }, - "Entitlement": { + "ReportMeta": { + "additionalProperties": false, "properties": { - "plan": { - "type": "string", - "title": "Plan" + "generated_at": { + "title": "Generated At", + "type": "string" }, - "weekly_limit": { + "request_id": { "anyOf": [ { - "type": "integer" + "type": "string" }, { "type": "null" } ], - "title": "Weekly Limit" + "title": "Request Id" }, - "used_this_week": { - "type": "integer", - "title": "Used This Week" + "text_source": { + "enum": [ + "llm", + "rules", + "mixed" + ], + "title": "Text Source", + "type": "string" }, - "left": { + "model": { "anyOf": [ { - "type": "integer" + "type": "string" }, { "type": "null" } ], - "title": "Left" - }, - "window_days": { - "type": "integer", - "title": "Window Days" - } - }, - "type": "object", - "required": [ - "plan", - "weekly_limit", - "used_this_week", - "left", - "window_days" - ], - "title": "Entitlement" - }, - "FocusArea": { - "additionalProperties": false, - "properties": { - "metric_id": { - "title": "Metric Id", - "type": "string" + "title": "Model" }, - "group": { - "enum": [ - "balance_load", - "stride", - "power_move", - "contact_follow_through" - ], - "title": "Group", + "prompt_version": { + "title": "Prompt Version", "type": "string" }, - "display_name": { - "title": "Display Name", - "type": "string" + "cache_hit": { + "title": "Cache Hit", + "type": "boolean" }, - "rating": { - "enum": [ - "on_target", - "satisfactory", - "off_target", - "not_rated" + "fallback_reason": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } ], - "title": "Rating", - "type": "string" + "title": "Fallback Reason" }, - "rating_label": { - "title": "Rating Label", + "input_schema_version": { + "title": "Input Schema Version", "type": "string" }, - "coach_message": { - "title": "Coach Message", + "measurement_definitions_version": { + "title": "Measurement Definitions Version", "type": "string" }, - "practice_feel": { - "title": "Practice Feel", + "benchmark_registry_version": { + "title": "Benchmark Registry Version", "type": "string" }, - "drill": { - "$ref": "#/components/schemas/Drill" - }, - "evidence_metric_ids": { - "items": { - "type": "string" - }, - "title": "Evidence Metric Ids", - "type": "array" + "coaching_rules_version": { + "title": "Coaching Rules Version", + "type": "string" } }, "required": [ - "metric_id", - "group", - "display_name", - "rating", - "rating_label", - "coach_message", - "practice_feel", - "drill", - "evidence_metric_ids" + "generated_at", + "request_id", + "text_source", + "model", + "prompt_version", + "cache_hit", + "fallback_reason", + "input_schema_version", + "measurement_definitions_version", + "benchmark_registry_version", + "coaching_rules_version" ], - "title": "FocusArea", + "title": "ReportMeta", "type": "object" }, - "FocusSummary": { + "RequestOut": { "properties": { - "metric_id": { + "id": { "type": "string", - "title": "Metric Id" + "format": "uuid", + "title": "Id" }, - "display_name": { + "user_id": { "type": "string", - "title": "Display Name" + "format": "uuid", + "title": "User Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "code": { + "type": "string", + "title": "Code" + }, + "at": { + "type": "string", + "format": "date-time", + "title": "At" + }, + "also_player": { + "type": "boolean", + "title": "Also Player" + }, + "status": { + "type": "string", + "enum": [ + "pending", + "approved", + "declined" + ], + "title": "Status" + } + }, + "type": "object", + "required": [ + "id", + "user_id", + "name", + "code", + "at", + "also_player", + "status" + ], + "title": "RequestOut" + }, + "RequestPage": { + "properties": { + "items": { + "items": { + "$ref": "#/components/schemas/RequestOut" + }, + "type": "array", + "title": "Items" }, - "drill_id": { + "next_cursor": { "anyOf": [ { "type": "string" @@ -3152,202 +12081,205 @@ "type": "null" } ], - "title": "Drill Id" + "title": "Next Cursor" + }, + "total_pending": { + "type": "integer", + "title": "Total Pending" } }, "type": "object", "required": [ - "metric_id", - "display_name", - "drill_id" + "items", + "total_pending" ], - "title": "FocusSummary" + "title": "RequestPage" }, - "ForgotPasswordIn": { + "ResetPasswordIn": { "properties": { - "email": { + "token": { "type": "string", - "maxLength": 254, - "title": "Email" + "maxLength": 256, + "minLength": 1, + "title": "Token" + }, + "password": { + "type": "string", + "maxLength": 128, + "minLength": 8, + "title": "Password" } }, "additionalProperties": false, "type": "object", "required": [ - "email" + "token", + "password" ], - "title": "ForgotPasswordIn" + "title": "ResetPasswordIn" }, - "GroupOut": { + "ReviewMessageOut": { "properties": { - "group": { + "id": { "type": "string", - "title": "Group" + "format": "uuid", + "title": "Id" }, - "display_name": { + "author_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Author Id" + }, + "from": { "type": "string", - "title": "Display Name" - } - }, - "type": "object", - "required": [ - "group", - "display_name" - ], - "title": "GroupOut" - }, - "GroupReport": { - "additionalProperties": false, - "properties": { - "group": { "enum": [ - "balance_load", - "stride", - "power_move", - "contact_follow_through" + "player", + "coach" ], - "title": "Group", - "type": "string" + "title": "From" }, - "display_name": { - "title": "Display Name", - "type": "string" + "at": { + "type": "string", + "format": "date-time", + "title": "At" }, - "score": { + "kind": { + "type": "string", + "const": "review", + "title": "Kind", + "default": "review" + }, + "cue": { + "type": "string", + "title": "Cue" + }, + "voice_seconds": { "anyOf": [ { - "type": "integer" + "type": "number" }, { "type": "null" } ], - "title": "Score" + "title": "Voice Seconds" }, - "rating": { - "enum": [ - "on_target", - "satisfactory", - "off_target", - "not_rated" - ], - "title": "Rating", - "type": "string" + "audio": { + "anyOf": [ + { + "$ref": "#/components/schemas/MediaRef" + }, + { + "type": "null" + } + ] }, - "rating_label": { - "title": "Rating Label", - "type": "string" + "findings": { + "items": { + "$ref": "#/components/schemas/Finding" + }, + "type": "array", + "title": "Findings" }, - "not_rated_reason": { + "drill_id": { "anyOf": [ { - "enum": [ - "measurement_unavailable", - "no_benchmark", - "no_measurements_available", - "measurements_unavailable", - "no_rated_measurements" - ], "type": "string" }, { "type": "null" } ], - "title": "Not Rated Reason" - }, - "summary": { - "title": "Summary", - "type": "string" + "title": "Drill Id" }, - "metric_ids": { - "items": { - "type": "string" - }, - "title": "Metric Ids", - "type": "array" - } - }, - "required": [ - "group", - "display_name", - "score", - "rating", - "rating_label", - "not_rated_reason", - "summary", - "metric_ids" - ], - "title": "GroupReport", - "type": "object" - }, - "Interval": { - "additionalProperties": false, - "properties": { - "lower": { - "title": "Lower", - "type": "number" + "drill_name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Drill Name" }, - "upper": { - "title": "Upper", - "type": "number" - } - }, - "required": [ - "lower", - "upper" - ], - "title": "Interval", - "type": "object" - }, - "Items_DrillLogOut_": { - "properties": { - "items": { - "items": { - "$ref": "#/components/schemas/DrillLogOut" - }, - "type": "array", - "title": "Items" - } - }, - "type": "object", - "required": [ - "items" - ], - "title": "Items[DrillLogOut]" - }, - "Items_RosterItem_": { - "properties": { - "items": { - "items": { - "$ref": "#/components/schemas/RosterItem" - }, - "type": "array", - "title": "Items" + "assignment_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Assignment Id" } }, "type": "object", "required": [ - "items" + "id", + "author_id", + "from", + "at", + "cue", + "voice_seconds", + "audio", + "findings", + "drill_id", + "drill_name" ], - "title": "Items[RosterItem]" + "title": "ReviewMessageOut" }, - "LastByMode": { + "ReviewOut": { "properties": { - "h": { + "coach_id": { "anyOf": [ { - "$ref": "#/components/schemas/LastSession" + "type": "string", + "format": "uuid" }, { "type": "null" } - ] + ], + "title": "Coach Id" }, - "p": { + "coach_name": { + "type": "string", + "title": "Coach Name" + }, + "cue": { + "type": "string", + "title": "Cue" + }, + "drill_id": { + "type": "string", + "title": "Drill Id" + }, + "verdicts": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Verdicts" + }, + "at": { + "type": "string", + "format": "date-time", + "title": "At" + }, + "voice_note": { "anyOf": [ { - "$ref": "#/components/schemas/LastSession" + "$ref": "#/components/schemas/MediaRef" }, { "type": "null" @@ -3356,435 +12288,566 @@ } }, "type": "object", - "title": "LastByMode" + "required": [ + "coach_id", + "coach_name", + "cue", + "drill_id", + "verdicts", + "at" + ], + "title": "ReviewOut", + "description": "The review shape every endpoint returns (GET /sessions/{id} and POST /sessions/{id}/review)." }, - "LastSession": { + "ReviewSubmit": { "properties": { - "session_id": { + "cue": { "type": "string", - "format": "uuid", - "title": "Session Id" + "maxLength": 200, + "minLength": 1, + "title": "Cue" }, - "overall_score": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Overall Score" + "drill_id": { + "type": "string", + "maxLength": 16, + "minLength": 1, + "title": "Drill Id" }, - "delta": { + "verdicts": { + "additionalProperties": { + "type": "string", + "enum": [ + "agree", + "change", + "later" + ] + }, + "type": "object", + "title": "Verdicts", + "default": {} + }, + "voice_note_upload_id": { "anyOf": [ { - "type": "integer" + "type": "string", + "format": "uuid" }, { "type": "null" } ], - "title": "Delta" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" + "title": "Voice Note Upload Id" }, - "focus_name": { + "voice_note_seconds": { "anyOf": [ { - "type": "string" + "type": "number", + "maximum": 120.0, + "exclusiveMinimum": 0.0 }, { "type": "null" } ], - "title": "Focus Name" + "title": "Voice Note Seconds" } }, + "additionalProperties": false, "type": "object", "required": [ - "session_id", - "overall_score", - "delta", - "created_at", - "focus_name" + "cue", + "drill_id" ], - "title": "LastSession" + "title": "ReviewSubmit", + "description": "Voice fields: omitted keeps the prior attachment, explicit null removes it (see model_fields_set)." }, - "Limitation": { - "additionalProperties": false, + "ReviewSubmitted": { "properties": { - "code": { - "title": "Code", - "type": "string" + "review": { + "$ref": "#/components/schemas/ReviewOut" }, - "text": { - "title": "Text", - "type": "string" + "thread_id": { + "type": "string", + "format": "uuid", + "title": "Thread Id" } }, + "type": "object", "required": [ - "code", - "text" + "review", + "thread_id" ], - "title": "Limitation", - "type": "object" + "title": "ReviewSubmitted" }, - "LoginIn": { + "ReviewSummary": { "properties": { - "email": { + "coach_name": { "type": "string", - "maxLength": 254, - "minLength": 1, - "title": "Email" + "title": "Coach Name" }, - "password": { + "at": { "type": "string", - "maxLength": 128, - "minLength": 1, - "title": "Password" + "format": "date-time", + "title": "At" + } + }, + "type": "object", + "required": [ + "coach_name", + "at" + ], + "title": "ReviewSummary" + }, + "RosterAddIn": { + "properties": { + "player_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "maxItems": 100, + "minItems": 1, + "title": "Player Ids" + }, + "group_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } + ], + "title": "Group Id" } }, "additionalProperties": false, "type": "object", "required": [ - "email", - "password" + "player_ids" ], - "title": "LoginIn" + "title": "RosterAddIn" }, - "MarksIn": { + "RosterAddOut": { "properties": { - "contact_frame": { - "type": "integer", - "minimum": 0.0, - "title": "Contact Frame" + "added_player_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Added Player Ids" }, - "contact_offset": { - "type": "integer", - "title": "Contact Offset" + "already_present_player_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Already Present Player Ids" + } + }, + "type": "object", + "required": [ + "added_player_ids", + "already_present_player_ids" + ], + "title": "RosterAddOut" + }, + "RosterItem": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" }, - "contact_source": { + "name": { "type": "string", - "enum": [ - "detected", - "suggested", - "manual" - ], - "title": "Contact Source" + "title": "Name" }, - "stride_start_frame": { - "type": "integer", - "minimum": 0.0, - "title": "Stride Start Frame" + "email": { + "type": "string", + "title": "Email" }, - "stride_end_frame": { - "type": "integer", - "minimum": 0.0, - "title": "Stride End Frame" + "focus": { + "type": "string", + "title": "Focus" }, - "pitcher_direction": { + "level": { "anyOf": [ { - "$ref": "#/components/schemas/PitcherDirection" + "type": "string" }, { "type": "null" } ], - "default": null + "title": "Level" + }, + "group_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Group Ids", + "default": [] + }, + "pending_count": { + "type": "integer", + "title": "Pending Count" + }, + "last": { + "$ref": "#/components/schemas/LastByMode" + }, + "recent": { + "$ref": "#/components/schemas/RecentByMode" } }, - "additionalProperties": false, "type": "object", "required": [ - "contact_frame", - "contact_offset", - "contact_source", - "stride_start_frame", - "stride_end_frame" + "id", + "name", + "email", + "focus", + "level", + "pending_count", + "last", + "recent" ], - "title": "MarksIn" + "title": "RosterItem", + "description": "A player as the coach sees them. Never carries body data (age, height, weight)." }, - "MeOut": { + "SendResult": { "properties": { - "user": { - "$ref": "#/components/schemas/UserOut" - }, - "team": { - "anyOf": [ + "message": { + "oneOf": [ { - "$ref": "#/components/schemas/TeamOut" + "$ref": "#/components/schemas/TextMessageOut" }, { - "type": "null" + "$ref": "#/components/schemas/VoiceMessageOut" + }, + { + "$ref": "#/components/schemas/SessionMessageOut" + }, + { + "$ref": "#/components/schemas/ReviewMessageOut" } - ] + ], + "title": "Message", + "discriminator": { + "propertyName": "kind", + "mapping": { + "review": "#/components/schemas/ReviewMessageOut", + "session": "#/components/schemas/SessionMessageOut", + "text": "#/components/schemas/TextMessageOut", + "voice": "#/components/schemas/VoiceMessageOut" + } + } }, - "entitlement": { - "$ref": "#/components/schemas/Entitlement" + "thread_status": { + "type": "string", + "enum": [ + "waiting_for_coach", + "reviewed" + ], + "title": "Thread Status" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "title": "Updated At" + } + }, + "type": "object", + "required": [ + "message", + "thread_status", + "updated_at" + ], + "title": "SendResult" + }, + "SessionEnvelope": { + "properties": { + "session": { + "$ref": "#/components/schemas/SessionOut" } }, "type": "object", "required": [ - "user", - "team", - "entitlement" + "session" ], - "title": "MeOut" + "title": "SessionEnvelope" }, - "MeUpdate": { + "SessionMessageOut": { "properties": { - "role": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "author_id": { "anyOf": [ { "type": "string", - "enum": [ - "player", - "coach" - ] + "format": "uuid" }, { "type": "null" } ], - "title": "Role" + "title": "Author Id" }, - "focus": { - "anyOf": [ - { - "type": "string", - "enum": [ - "h", - "p", - "both" - ] - }, - { - "type": "null" - } + "from": { + "type": "string", + "enum": [ + "player", + "coach" ], - "title": "Focus" + "title": "From" }, - "unit": { + "at": { + "type": "string", + "format": "date-time", + "title": "At" + }, + "kind": { + "type": "string", + "const": "session", + "title": "Kind", + "default": "session" + }, + "session_id": { "anyOf": [ { "type": "string", - "enum": [ - "imperial", - "metric" - ] + "format": "uuid" }, { "type": "null" } ], - "title": "Unit" + "title": "Session Id" }, - "private_videos": { + "label": { "anyOf": [ { - "type": "boolean" + "type": "string" }, { "type": "null" } ], - "title": "Private Videos" + "title": "Label" }, - "profile": { + "score": { "anyOf": [ { - "$ref": "#/components/schemas/ProfileUpdate" + "type": "integer" }, { "type": "null" } - ] + ], + "title": "Score" } }, - "additionalProperties": false, "type": "object", - "title": "MeUpdate", - "description": "Partial update: only the fields sent are changed. Profile nulls clear a value; top-level nulls are rejected." + "required": [ + "id", + "author_id", + "from", + "at", + "session_id", + "label", + "score" + ], + "title": "SessionMessageOut" }, - "MeasurementReport": { - "additionalProperties": false, + "SessionOut": { "properties": { - "metric_id": { - "title": "Metric Id", - "type": "string" + "id": { + "type": "string", + "format": "uuid", + "title": "Id" }, - "display_name": { - "title": "Display Name", - "type": "string" + "owner_id": { + "type": "string", + "format": "uuid", + "title": "Owner Id" }, - "group": { - "enum": [ - "balance_load", - "stride", - "power_move", - "contact_follow_through" - ], - "title": "Group", - "type": "string" + "is_self": { + "type": "boolean", + "title": "Is Self" + }, + "mode": { + "type": "string", + "title": "Mode" }, "status": { - "enum": [ - "available", - "limited", - "unavailable" - ], - "title": "Status", - "type": "string" + "type": "string", + "title": "Status" }, - "value": { + "created_at": { + "type": "string", + "format": "date-time", + "title": "Created At" + }, + "analyzed_at": { "anyOf": [ { - "type": "number" + "type": "string", + "format": "date-time" }, { "type": "null" } ], - "title": "Value" + "title": "Analyzed At" }, - "unit": { - "title": "Unit", - "type": "string" + "athlete": { + "additionalProperties": true, + "type": "object", + "title": "Athlete" }, - "display_value": { + "duration_sec": { + "type": "number", + "title": "Duration Sec" + }, + "fps": { + "type": "integer", + "title": "Fps" + }, + "marks": { + "additionalProperties": true, + "type": "object", + "title": "Marks" + }, + "report": { "anyOf": [ { - "type": "string" + "$ref": "#/components/schemas/SwingReport" }, { "type": "null" } ], - "title": "Display Value" + "description": "Null while status is pending" }, - "score": { + "review": { "anyOf": [ { - "type": "integer" + "$ref": "#/components/schemas/ReviewOut" }, { "type": "null" } - ], - "title": "Score" - }, - "rating": { - "enum": [ - "on_target", - "satisfactory", - "off_target", - "not_rated" - ], - "title": "Rating", - "type": "string" - }, - "rating_label": { - "title": "Rating Label", - "type": "string" + ] }, - "rating_is_tentative": { - "title": "Rating Is Tentative", - "type": "boolean" + "media": { + "$ref": "#/components/schemas/MediaOut" }, - "not_rated_reason": { + "previous": { "anyOf": [ { - "enum": [ - "measurement_unavailable", - "no_benchmark", - "no_measurements_available", - "measurements_unavailable", - "no_rated_measurements" - ], - "type": "string" + "$ref": "#/components/schemas/PreviousOut" }, { "type": "null" } - ], - "title": "Not Rated Reason" + ] }, - "benchmark": { + "ordinal": { + "type": "integer", + "title": "Ordinal" + } + }, + "type": "object", + "required": [ + "id", + "owner_id", + "is_self", + "mode", + "status", + "created_at", + "analyzed_at", + "athlete", + "duration_sec", + "fps", + "marks", + "report", + "review", + "media", + "previous", + "ordinal" + ], + "title": "SessionOut" + }, + "SessionSummary": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "owner_id": { + "type": "string", + "format": "uuid", + "title": "Owner Id" + }, + "mode": { + "type": "string", + "title": "Mode" + }, + "is_self": { + "type": "boolean", + "title": "Is Self" + }, + "athlete_name": { + "type": "string", + "title": "Athlete Name" + }, + "status": { + "type": "string", + "title": "Status" + }, + "overall_score": { "anyOf": [ { - "$ref": "#/components/schemas/BenchmarkOut" + "type": "integer" }, { "type": "null" } - ] + ], + "title": "Overall Score" }, - "what_it_means": { - "title": "What It Means", - "type": "string" + "overall_score_is_tentative": { + "type": "boolean", + "title": "Overall Score Is Tentative" }, - "result_text": { + "focus": { "anyOf": [ { - "type": "string" + "$ref": "#/components/schemas/FocusSummary" }, { "type": "null" } - ], - "title": "Result Text" + ] }, - "coach_tip": { + "review": { "anyOf": [ { - "type": "string" + "$ref": "#/components/schemas/ReviewSummary" }, { "type": "null" } - ], - "title": "Coach Tip" - }, - "limitations": { - "items": { - "$ref": "#/components/schemas/Limitation" - }, - "title": "Limitations", - "type": "array" - } - }, - "required": [ - "metric_id", - "display_name", - "group", - "status", - "value", - "unit", - "display_value", - "score", - "rating", - "rating_label", - "rating_is_tentative", - "not_rated_reason", - "benchmark", - "what_it_means", - "result_text", - "coach_tip", - "limitations" - ], - "title": "MeasurementReport", - "type": "object" - }, - "MediaOut": { - "properties": { - "video_url": { - "type": "string", - "title": "Video Url" + ] }, "thumbnail_url": { "anyOf": [ @@ -3797,213 +12860,180 @@ ], "title": "Thumbnail Url" }, - "expires_at": { + "created_at": { "type": "string", "format": "date-time", - "title": "Expires At" + "title": "Created At" } }, "type": "object", "required": [ - "video_url", + "id", + "owner_id", + "mode", + "is_self", + "athlete_name", + "status", + "overall_score", + "overall_score_is_tentative", + "focus", + "review", "thumbnail_url", - "expires_at" + "created_at" ], - "title": "MediaOut" + "title": "SessionSummary" }, - "MetricOut": { + "SetIn": { "properties": { - "metric_id": { - "type": "string", - "title": "Metric Id" - }, - "display_name": { - "type": "string", - "title": "Display Name" - }, - "group": { - "type": "string", - "title": "Group" + "set_number": { + "type": "integer", + "minimum": 1.0, + "title": "Set Number" }, - "unit": { - "type": "string", - "title": "Unit" + "reps_done": { + "type": "integer", + "minimum": 1.0, + "title": "Reps Done" }, - "what_it_means": { + "day": { "type": "string", - "title": "What It Means" + "format": "date", + "title": "Day" } }, - "type": "object", - "required": [ - "metric_id", - "display_name", - "group", - "unit", - "what_it_means" - ], - "title": "MetricOut" - }, - "Overview": { "additionalProperties": false, - "properties": { - "headline": { - "title": "Headline", - "type": "string" - } - }, + "type": "object", "required": [ - "headline" + "set_number", + "reps_done", + "day" ], - "title": "Overview", - "type": "object" + "title": "SetIn" }, - "Page_SessionSummary_": { + "SetLogOut": { "properties": { - "items": { - "items": { - "$ref": "#/components/schemas/SessionSummary" - }, - "type": "array", - "title": "Items" + "id": { + "type": "string", + "format": "uuid", + "title": "Id" }, - "next_cursor": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Next Cursor" + "set_number": { + "type": "integer", + "title": "Set Number" + }, + "reps_done": { + "type": "integer", + "title": "Reps Done" + }, + "day": { + "type": "string", + "format": "date", + "title": "Day" } }, "type": "object", "required": [ - "items" + "id", + "set_number", + "reps_done", + "day" ], - "title": "Page[SessionSummary]" + "title": "SetLogOut" }, - "PitcherDirection": { + "SetResult": { "properties": { - "from": { - "prefixItems": [ - { - "type": "number", - "maximum": 1.0, - "minimum": 0.0 - }, - { - "type": "number", - "maximum": 1.0, - "minimum": 0.0 - } - ], - "type": "array", - "maxItems": 2, - "minItems": 2, - "title": "From" + "assignment": { + "$ref": "#/components/schemas/AssignmentOut" }, - "to": { - "prefixItems": [ - { - "type": "number", - "maximum": 1.0, - "minimum": 0.0 - }, - { - "type": "number", - "maximum": 1.0, - "minimum": 0.0 - } - ], - "type": "array", - "maxItems": 2, - "minItems": 2, - "title": "To" + "set_log": { + "$ref": "#/components/schemas/SetLogOut" } }, - "additionalProperties": false, "type": "object", "required": [ - "from", - "to" + "assignment", + "set_log" ], - "title": "PitcherDirection" + "title": "SetResult" }, - "PreviousOut": { + "SettingsEnvelope": { "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "overall_score": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Overall Score" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" + "settings": { + "$ref": "#/components/schemas/SettingsOut" } }, "type": "object", "required": [ - "id", - "overall_score", - "created_at" + "settings" ], - "title": "PreviousOut" + "title": "SettingsEnvelope" }, - "ProfileOut": { + "SettingsOut": { "properties": { - "name": { - "type": "string", - "title": "Name" + "coach_can_see_sessions": { + "type": "boolean", + "title": "Coach Can See Sessions" }, - "age": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Age" + "share_with_parent": { + "type": "boolean", + "title": "Share With Parent" }, - "height_cm": { + "parent_email": { "anyOf": [ { - "type": "number" + "type": "string" }, { "type": "null" } ], - "title": "Height Cm" + "title": "Parent Email" }, - "weight_kg": { + "auto_monthly_report": { + "type": "boolean", + "title": "Auto Monthly Report" + }, + "private_links": { + "type": "boolean", + "title": "Private Links" + }, + "clips_as_examples": { + "type": "boolean", + "title": "Clips As Examples" + }, + "help_improve_ai": { + "type": "boolean", + "title": "Help Improve Ai" + }, + "notify_results": { + "type": "boolean", + "title": "Notify Results" + }, + "notify_coach": { + "type": "boolean", + "title": "Notify Coach" + }, + "notify_drills": { + "type": "boolean", + "title": "Notify Drills" + }, + "notify_weekly": { + "type": "boolean", + "title": "Notify Weekly" + }, + "consented_at": { "anyOf": [ { - "type": "number" + "type": "string", + "format": "date-time" }, { "type": "null" } ], - "title": "Weight Kg" + "title": "Consented At" }, - "bats": { + "consent_version": { "anyOf": [ { "type": "string" @@ -4012,575 +13042,493 @@ "type": "null" } ], - "title": "Bats" + "title": "Consent Version" }, - "throws": { + "skip_filming_guide": { + "type": "boolean", + "title": "Skip Filming Guide" + }, + "version": { + "type": "integer", + "title": "Version" + } + }, + "type": "object", + "required": [ + "coach_can_see_sessions", + "share_with_parent", + "parent_email", + "auto_monthly_report", + "private_links", + "clips_as_examples", + "help_improve_ai", + "notify_results", + "notify_coach", + "notify_drills", + "notify_weekly", + "consented_at", + "consent_version", + "skip_filming_guide", + "version" + ], + "title": "SettingsOut" + }, + "SettingsPatch": { + "properties": { + "coach_can_see_sessions": { "anyOf": [ { - "type": "string" + "type": "boolean" }, { "type": "null" } ], - "title": "Throws" + "title": "Coach Can See Sessions" }, - "level": { + "share_with_parent": { "anyOf": [ { - "type": "string" + "type": "boolean" }, { "type": "null" } ], - "title": "Level" - } - }, - "type": "object", - "required": [ - "name", - "age", - "height_cm", - "weight_kg", - "bats", - "throws", - "level" - ], - "title": "ProfileOut" - }, - "ProfileUpdate": { - "properties": { - "name": { + "title": "Share With Parent" + }, + "parent_email": { "anyOf": [ { "type": "string", - "maxLength": 80 + "maxLength": 254 }, { "type": "null" } ], - "title": "Name" + "title": "Parent Email" }, - "age": { + "auto_monthly_report": { "anyOf": [ { - "type": "integer", - "maximum": 70.0, - "minimum": 5.0 + "type": "boolean" }, { "type": "null" } ], - "title": "Age" + "title": "Auto Monthly Report" }, - "height_cm": { + "private_links": { "anyOf": [ { - "type": "number", - "maximum": 230.0, - "minimum": 90.0 + "type": "boolean" }, { "type": "null" } ], - "title": "Height Cm" + "title": "Private Links" }, - "weight_kg": { + "clips_as_examples": { "anyOf": [ { - "type": "number", - "maximum": 200.0, - "minimum": 20.0 + "type": "boolean" }, { "type": "null" } ], - "title": "Weight Kg" + "title": "Clips As Examples" }, - "bats": { + "help_improve_ai": { "anyOf": [ { - "type": "string", - "enum": [ - "L", - "R", - "S" - ] + "type": "boolean" }, { "type": "null" } ], - "title": "Bats" + "title": "Help Improve Ai" }, - "throws": { + "notify_results": { "anyOf": [ { - "type": "string", - "enum": [ - "L", - "R" - ] + "type": "boolean" }, { "type": "null" } ], - "title": "Throws" + "title": "Notify Results" }, - "level": { + "notify_coach": { "anyOf": [ { - "type": "string", - "enum": [ - "youth", - "high_school", - "college", - "adult" - ] + "type": "boolean" }, { "type": "null" } ], - "title": "Level" - } - }, - "additionalProperties": false, - "type": "object", - "title": "ProfileUpdate" - }, - "PubSubMessage": { - "properties": { - "data": { - "type": "string", - "maxLength": 100000, - "title": "Data", - "default": "" - } - }, - "type": "object", - "title": "PubSubMessage" - }, - "PubSubPushIn": { - "properties": { - "message": { - "$ref": "#/components/schemas/PubSubMessage" - } - }, - "type": "object", - "required": [ - "message" - ], - "title": "PubSubPushIn" - }, - "QueueItem": { - "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "owner_id": { - "type": "string", - "format": "uuid", - "title": "Owner Id" - }, - "mode": { - "type": "string", - "title": "Mode" - }, - "is_self": { - "type": "boolean", - "title": "Is Self" - }, - "athlete_name": { - "type": "string", - "title": "Athlete Name" - }, - "status": { - "type": "string", - "title": "Status" + "title": "Notify Coach" }, - "overall_score": { + "notify_drills": { "anyOf": [ { - "type": "integer" + "type": "boolean" }, { "type": "null" } ], - "title": "Overall Score" + "title": "Notify Drills" }, - "focus": { + "notify_weekly": { "anyOf": [ { - "$ref": "#/components/schemas/FocusSummary" + "type": "boolean" }, { "type": "null" } - ] + ], + "title": "Notify Weekly" }, - "review": { + "skip_filming_guide": { "anyOf": [ { - "$ref": "#/components/schemas/ReviewSummary" + "type": "boolean" }, { "type": "null" } - ] + ], + "title": "Skip Filming Guide" }, - "thumbnail_url": { + "expected_version": { "anyOf": [ { - "type": "string" + "type": "integer", + "minimum": 1.0 }, { "type": "null" } ], - "title": "Thumbnail Url" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "owner_name": { - "type": "string", - "title": "Owner Name" + "title": "Expected Version" } }, + "additionalProperties": false, "type": "object", - "required": [ - "id", - "owner_id", - "mode", - "is_self", - "athlete_name", - "status", - "overall_score", - "focus", - "review", - "thumbnail_url", - "created_at", - "owner_name" - ], - "title": "QueueItem" + "title": "SettingsPatch" }, - "QueueResponse": { + "SocialAuthOut": { "properties": { - "open": { - "items": { - "$ref": "#/components/schemas/QueueItem" - }, - "type": "array", - "title": "Open" + "user": { + "$ref": "#/components/schemas/UserOut" }, - "reviewed_today": { - "items": { - "$ref": "#/components/schemas/QueueItem" - }, - "type": "array", - "title": "Reviewed Today" + "tokens": { + "$ref": "#/components/schemas/TokensOut" + }, + "is_new": { + "type": "boolean", + "title": "Is New" } }, "type": "object", "required": [ - "open", - "reviewed_today" + "user", + "tokens", + "is_new" ], - "title": "QueueResponse" + "title": "SocialAuthOut" }, - "ReceiptIn": { + "SocialIn": { "properties": { - "platform": { + "provider": { "type": "string", "enum": [ - "ios", - "android" + "apple", + "google" ], - "title": "Platform" + "title": "Provider" }, - "product_id": { + "id_token": { "type": "string", - "maxLength": 64, + "maxLength": 8192, "minLength": 1, - "title": "Product Id" - }, - "signed_transaction": { - "anyOf": [ - { - "type": "string", - "maxLength": 32000 - }, - { - "type": "null" - } - ], - "title": "Signed Transaction" + "title": "Id Token" }, - "purchase_token": { - "anyOf": [ - { - "type": "string", - "maxLength": 4096 - }, - { - "type": "null" - } + "role": { + "type": "string", + "enum": [ + "player", + "coach" ], - "title": "Purchase Token" + "title": "Role", + "default": "player" } }, "additionalProperties": false, "type": "object", "required": [ - "platform", - "product_id" + "provider", + "id_token" ], - "title": "ReceiptIn" + "title": "SocialIn" }, - "ReceiptOut": { + "StaffCodeBody": { "properties": { - "entitlement": { - "$ref": "#/components/schemas/Entitlement" + "staff_code": { + "$ref": "#/components/schemas/StaffCodeOut" } }, "type": "object", "required": [ - "entitlement" + "staff_code" ], - "title": "ReceiptOut" + "title": "StaffCodeBody" }, - "RecentByMode": { + "StaffCodeCreate": { "properties": { - "h": { - "items": { - "type": "integer" - }, - "type": "array", - "title": "H", - "default": [] + "role": { + "type": "string", + "enum": [ + "coach", + "assistant" + ], + "title": "Role" }, - "p": { - "items": { - "type": "integer" - }, - "type": "array", - "title": "P", - "default": [] - } - }, - "type": "object", - "title": "RecentByMode" - }, - "RefreshIn": { - "properties": { - "refresh_token": { + "expires_days": { + "type": "integer", + "enum": [ + 1, + 7, + 30 + ], + "title": "Expires Days" + }, + "max_uses": { + "type": "integer", + "enum": [ + 1, + 5, + 20 + ], + "title": "Max Uses" + }, + "approval": { "type": "string", - "maxLength": 256, - "minLength": 1, - "title": "Refresh Token" + "enum": [ + "admin", + "auto" + ], + "title": "Approval" } }, "additionalProperties": false, "type": "object", "required": [ - "refresh_token" + "role", + "expires_days", + "max_uses", + "approval" ], - "title": "RefreshIn" + "title": "StaffCodeCreate" }, - "RegisterIn": { + "StaffCodeOut": { "properties": { - "email": { - "type": "string", - "maxLength": 254, - "title": "Email" - }, - "password": { + "code": { "type": "string", - "maxLength": 128, - "minLength": 8, - "title": "Password" + "title": "Code" }, "role": { "type": "string", "enum": [ - "player", - "coach" + "coach", + "assistant" ], "title": "Role" + }, + "expires": { + "type": "string", + "format": "date-time", + "title": "Expires" + }, + "uses": { + "type": "integer", + "title": "Uses" + }, + "max_uses": { + "type": "integer", + "title": "Max Uses" + }, + "approval": { + "type": "string", + "enum": [ + "admin", + "auto" + ], + "title": "Approval" + }, + "status": { + "type": "string", + "enum": [ + "active", + "expired", + "revoked" + ], + "title": "Status" } }, - "additionalProperties": false, "type": "object", "required": [ - "email", - "password", - "role" + "code", + "role", + "expires", + "uses", + "max_uses", + "approval", + "status" ], - "title": "RegisterIn" + "title": "StaffCodeOut" }, - "ReportMeta": { + "SwingReport": { "additionalProperties": false, "properties": { - "generated_at": { - "title": "Generated At", + "schema_version": { + "const": "1.0", + "title": "Schema Version", "type": "string" }, - "request_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Request Id" - }, - "text_source": { - "enum": [ - "llm", - "rules", - "mixed" - ], - "title": "Text Source", + "analysis_id": { + "title": "Analysis Id", "type": "string" }, - "model": { + "analysis_revision": { + "title": "Analysis Revision", + "type": "integer" + }, + "overall_score": { "anyOf": [ { - "type": "string" + "type": "integer" }, { "type": "null" } ], - "title": "Model" - }, - "prompt_version": { - "title": "Prompt Version", - "type": "string" + "title": "Overall Score" }, - "cache_hit": { - "title": "Cache Hit", + "overall_score_is_tentative": { + "title": "Overall Score Is Tentative", "type": "boolean" }, - "fallback_reason": { + "overview": { + "$ref": "#/components/schemas/Overview" + }, + "groups": { + "items": { + "$ref": "#/components/schemas/GroupReport" + }, + "title": "Groups", + "type": "array" + }, + "focus_area": { "anyOf": [ { - "type": "string" + "$ref": "#/components/schemas/FocusArea" }, { "type": "null" } - ], - "title": "Fallback Reason" - }, - "input_schema_version": { - "title": "Input Schema Version", - "type": "string" + ] }, - "measurement_definitions_version": { - "title": "Measurement Definitions Version", - "type": "string" + "measurements": { + "items": { + "$ref": "#/components/schemas/MeasurementReport" + }, + "title": "Measurements", + "type": "array" }, - "benchmark_registry_version": { - "title": "Benchmark Registry Version", - "type": "string" + "data_quality": { + "items": { + "$ref": "#/components/schemas/DataQualityNote" + }, + "title": "Data Quality", + "type": "array" }, - "coaching_rules_version": { - "title": "Coaching Rules Version", - "type": "string" + "meta": { + "$ref": "#/components/schemas/ReportMeta" } }, "required": [ - "generated_at", - "request_id", - "text_source", - "model", - "prompt_version", - "cache_hit", - "fallback_reason", - "input_schema_version", - "measurement_definitions_version", - "benchmark_registry_version", - "coaching_rules_version" + "schema_version", + "analysis_id", + "analysis_revision", + "overall_score", + "overall_score_is_tentative", + "overview", + "groups", + "focus_area", + "measurements", + "data_quality", + "meta" ], - "title": "ReportMeta", + "title": "SwingReport", "type": "object" }, - "ResetPasswordIn": { - "properties": { - "token": { - "type": "string", - "maxLength": 256, - "minLength": 1, - "title": "Token" - }, - "password": { - "type": "string", - "maxLength": 128, - "minLength": 8, - "title": "Password" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "token", - "password" - ], - "title": "ResetPasswordIn" - }, - "ReviewCreate": { + "TeamCreate": { "properties": { - "cue": { - "type": "string", - "maxLength": 200, - "minLength": 1, - "title": "Cue" - }, - "drill_id": { + "name": { "type": "string", - "maxLength": 16, - "minLength": 1, - "title": "Drill Id" - }, - "verdicts": { - "additionalProperties": { - "type": "string", - "enum": [ - "agree", - "change", - "later" - ] - }, - "type": "object", - "title": "Verdicts", - "default": {} + "maxLength": 60, + "minLength": 2, + "title": "Name" + }, + "coach_name": { + "type": "string", + "maxLength": 60, + "minLength": 2, + "title": "Coach Name" + }, + "coaching": { + "type": "string", + "enum": [ + "h", + "p", + "both" + ], + "title": "Coaching" } }, "additionalProperties": false, "type": "object", "required": [ - "cue", - "drill_id" + "name", + "coach_name", + "coaching" ], - "title": "ReviewCreate" + "title": "TeamCreate" }, - "ReviewOut": { + "TeamOut": { "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "code": { + "type": "string", + "title": "Code" + }, + "name": { + "type": "string", + "title": "Name" + }, "coach_id": { "type": "string", "format": "uuid", @@ -4590,145 +13538,112 @@ "type": "string", "title": "Coach Name" }, - "cue": { - "type": "string", - "title": "Cue" - }, - "drill_id": { + "coaching": { "type": "string", - "title": "Drill Id" - }, - "verdicts": { - "additionalProperties": { - "type": "string" - }, - "type": "object", - "title": "Verdicts" + "title": "Coaching" }, - "at": { + "created_at": { "type": "string", "format": "date-time", - "title": "At" + "title": "Created At" } }, "type": "object", "required": [ + "id", + "code", + "name", "coach_id", "coach_name", - "cue", - "drill_id", - "verdicts", - "at" + "coaching", + "created_at" ], - "title": "ReviewOut", - "description": "The review shape every endpoint returns (GET /sessions/{id} and POST /sessions/{id}/review)." + "title": "TeamOut", + "description": "The team shape every endpoint returns (GET /me, team create, lookup and join)." }, - "ReviewResponse": { + "TeamResponse": { "properties": { - "review": { - "$ref": "#/components/schemas/ReviewOut" + "team": { + "$ref": "#/components/schemas/TeamOut" } }, "type": "object", "required": [ - "review" + "team" ], - "title": "ReviewResponse" + "title": "TeamResponse" }, - "ReviewSummary": { + "TeamSummaryOut": { "properties": { + "code": { + "type": "string", + "title": "Code" + }, + "name": { + "type": "string", + "title": "Name" + }, "coach_name": { "type": "string", "title": "Coach Name" }, - "at": { + "coaching": { "type": "string", - "format": "date-time", - "title": "At" + "title": "Coaching" } }, "type": "object", "required": [ + "code", + "name", "coach_name", - "at" + "coaching" ], - "title": "ReviewSummary" + "title": "TeamSummaryOut", + "description": "What a player sees before joining: no ids." }, - "RosterItem": { + "TeamSummaryResponse": { "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "name": { - "type": "string", - "title": "Name" - }, - "email": { - "type": "string", - "title": "Email" - }, - "focus": { - "type": "string", - "title": "Focus" - }, - "level": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Level" - }, - "pending_count": { - "type": "integer", - "title": "Pending Count" - }, - "last": { - "$ref": "#/components/schemas/LastByMode" - }, - "recent": { - "$ref": "#/components/schemas/RecentByMode" + "team": { + "$ref": "#/components/schemas/TeamSummaryOut" } }, "type": "object", "required": [ - "id", - "name", - "email", - "focus", - "level", - "pending_count", - "last", - "recent" + "team" ], - "title": "RosterItem", - "description": "A player as the coach sees them. Never carries body data (age, height, weight)." + "title": "TeamSummaryResponse" }, - "SessionEnvelope": { + "TextIn": { "properties": { - "session": { - "$ref": "#/components/schemas/SessionOut" + "kind": { + "type": "string", + "const": "text", + "title": "Kind" + }, + "text": { + "type": "string", + "maxLength": 500, + "minLength": 1, + "title": "Text" } }, + "additionalProperties": false, "type": "object", "required": [ - "session" + "kind", + "text" ], - "title": "SessionEnvelope" + "title": "TextIn" }, - "SessionIn": { + "TextMessageOut": { "properties": { - "video_upload_id": { + "id": { "type": "string", "format": "uuid", - "title": "Video Upload Id" + "title": "Id" }, - "thumbnail_upload_id": { + "author_id": { "anyOf": [ { "type": "string", @@ -4738,236 +13653,370 @@ "type": "null" } ], - "title": "Thumbnail Upload Id" + "title": "Author Id" }, - "mode": { + "from": { "type": "string", "enum": [ - "h", - "p" + "player", + "coach" ], - "title": "Mode" - }, - "is_self": { - "type": "boolean", - "title": "Is Self" - }, - "athlete": { - "anyOf": [ - { - "$ref": "#/components/schemas/AthleteIn" - }, - { - "type": "null" - } - ] + "title": "From" }, - "duration_sec": { - "type": "number", - "exclusiveMinimum": 0.0, - "title": "Duration Sec" + "at": { + "type": "string", + "format": "date-time", + "title": "At" }, - "fps": { - "type": "integer", - "maximum": 240.0, - "minimum": 1.0, - "title": "Fps" + "kind": { + "type": "string", + "const": "text", + "title": "Kind", + "default": "text" }, - "marks": { - "$ref": "#/components/schemas/MarksIn" + "text": { + "type": "string", + "title": "Text" } }, - "additionalProperties": false, "type": "object", "required": [ - "video_upload_id", - "mode", - "is_self", - "duration_sec", - "fps", - "marks" + "id", + "author_id", + "from", + "at", + "text" ], - "title": "SessionIn" + "title": "TextMessageOut" }, - "SessionOut": { + "ThreadEnvelope": { + "properties": { + "thread": { + "$ref": "#/components/schemas/ThreadOut" + } + }, + "type": "object", + "required": [ + "thread" + ], + "title": "ThreadEnvelope" + }, + "ThreadOut": { "properties": { "id": { "type": "string", "format": "uuid", "title": "Id" }, - "owner_id": { - "type": "string", - "format": "uuid", - "title": "Owner Id" - }, - "is_self": { - "type": "boolean", - "title": "Is Self" - }, "mode": { "type": "string", - "title": "Mode" - }, - "status": { - "type": "string", - "title": "Status" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" + "enum": [ + "h", + "p" + ], + "title": "Mode" }, - "analyzed_at": { + "session_id": { "anyOf": [ { "type": "string", - "format": "date-time" + "format": "uuid" }, { "type": "null" } ], - "title": "Analyzed At" - }, - "athlete": { - "additionalProperties": true, - "type": "object", - "title": "Athlete" - }, - "duration_sec": { - "type": "number", - "title": "Duration Sec" - }, - "fps": { - "type": "integer", - "title": "Fps" + "title": "Session Id" }, - "marks": { - "additionalProperties": true, - "type": "object", - "title": "Marks" + "session_label": { + "type": "string", + "title": "Session Label" }, - "report": { + "score": { "anyOf": [ { - "$ref": "#/components/schemas/SwingReport" + "type": "integer" }, { "type": "null" } ], - "description": "Null while status is pending" + "title": "Score" }, - "review": { + "tone": { + "type": "string", + "enum": [ + "g", + "y", + "r" + ], + "title": "Tone" + }, + "coach_id": { "anyOf": [ { - "$ref": "#/components/schemas/ReviewOut" + "type": "string", + "format": "uuid" }, { "type": "null" } - ] + ], + "title": "Coach Id" }, - "media": { - "$ref": "#/components/schemas/MediaOut" + "coach_name": { + "type": "string", + "title": "Coach Name" }, - "previous": { + "player_id": { + "type": "string", + "format": "uuid", + "title": "Player Id" + }, + "player_name": { + "type": "string", + "title": "Player Name" + }, + "status": { + "type": "string", + "enum": [ + "waiting_for_coach", + "reviewed" + ], + "title": "Status" + }, + "unread_for_player": { + "type": "boolean", + "title": "Unread For Player" + }, + "unread_for_coach": { + "type": "boolean", + "title": "Unread For Coach" + }, + "updated_at": { + "type": "string", + "format": "date-time", + "title": "Updated At" + }, + "messages": { + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/TextMessageOut" + }, + { + "$ref": "#/components/schemas/VoiceMessageOut" + }, + { + "$ref": "#/components/schemas/SessionMessageOut" + }, + { + "$ref": "#/components/schemas/ReviewMessageOut" + } + ], + "discriminator": { + "propertyName": "kind", + "mapping": { + "review": "#/components/schemas/ReviewMessageOut", + "session": "#/components/schemas/SessionMessageOut", + "text": "#/components/schemas/TextMessageOut", + "voice": "#/components/schemas/VoiceMessageOut" + } + } + }, + "type": "array", + "title": "Messages" + }, + "next_message_cursor": { "anyOf": [ { - "$ref": "#/components/schemas/PreviousOut" + "type": "string" }, { "type": "null" } - ] - }, - "ordinal": { - "type": "integer", - "title": "Ordinal" + ], + "title": "Next Message Cursor" } }, "type": "object", "required": [ "id", - "owner_id", - "is_self", "mode", + "session_id", + "session_label", + "score", + "tone", + "coach_id", + "coach_name", + "player_id", + "player_name", "status", - "created_at", - "analyzed_at", - "athlete", - "duration_sec", - "fps", - "marks", - "report", - "review", - "media", - "previous", - "ordinal" + "unread_for_player", + "unread_for_coach", + "updated_at", + "messages" ], - "title": "SessionOut" + "title": "ThreadOut" }, - "SessionSummary": { + "TokensOut": { "properties": { - "id": { + "access_token": { "type": "string", - "format": "uuid", - "title": "Id" + "title": "Access Token" }, - "owner_id": { + "refresh_token": { "type": "string", - "format": "uuid", - "title": "Owner Id" + "title": "Refresh Token" }, - "mode": { + "expires_in": { + "type": "integer", + "title": "Expires In" + } + }, + "type": "object", + "required": [ + "access_token", + "refresh_token", + "expires_in" + ], + "title": "TokensOut" + }, + "UnreadCount": { + "properties": { + "count": { + "type": "integer", + "minimum": 0.0, + "title": "Count" + } + }, + "type": "object", + "required": [ + "count" + ], + "title": "UnreadCount" + }, + "UploadIn": { + "properties": { + "kind": { "type": "string", - "title": "Mode" - }, - "is_self": { - "type": "boolean", - "title": "Is Self" + "enum": [ + "video", + "thumbnail", + "audio", + "drill_video" + ], + "title": "Kind" }, - "athlete_name": { + "content_type": { "type": "string", - "title": "Athlete Name" + "maxLength": 40, + "minLength": 1, + "title": "Content Type" }, - "status": { - "type": "string", - "title": "Status" + "size_bytes": { + "type": "integer", + "exclusiveMinimum": 0.0, + "title": "Size Bytes" }, - "overall_score": { + "duration_sec": { "anyOf": [ { - "type": "integer" + "type": "number", + "exclusiveMinimum": 0.0 }, { "type": "null" } ], - "title": "Overall Score" + "title": "Duration Sec" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "kind", + "content_type", + "size_bytes" + ], + "title": "UploadIn" + }, + "UploadOut": { + "properties": { + "upload_id": { + "type": "string", + "format": "uuid", + "title": "Upload Id" + }, + "url": { + "type": "string", + "title": "Url" + }, + "headers": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "title": "Headers" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "title": "Expires At" + } + }, + "type": "object", + "required": [ + "upload_id", + "url", + "headers", + "expires_at" + ], + "title": "UploadOut" + }, + "UserBody": { + "properties": { + "user": { + "$ref": "#/components/schemas/UserOut" + } + }, + "type": "object", + "required": [ + "user" + ], + "title": "UserBody" + }, + "UserOut": { + "properties": { + "id": { + "type": "string", + "format": "uuid", + "title": "Id" + }, + "email": { + "type": "string", + "title": "Email" + }, + "role": { + "type": "string", + "title": "Role" }, "focus": { - "anyOf": [ - { - "$ref": "#/components/schemas/FocusSummary" - }, - { - "type": "null" - } - ] + "type": "string", + "title": "Focus" }, - "review": { - "anyOf": [ - { - "$ref": "#/components/schemas/ReviewSummary" - }, - { - "type": "null" - } - ] + "profile": { + "$ref": "#/components/schemas/ProfileOut" }, - "thumbnail_url": { + "unit": { + "type": "string", + "title": "Unit" + }, + "private_videos": { + "type": "boolean", + "title": "Private Videos" + }, + "team_code": { "anyOf": [ { "type": "string" @@ -4976,7 +14025,7 @@ "type": "null" } ], - "title": "Thumbnail Url" + "title": "Team Code" }, "created_at": { "type": "string", @@ -4987,463 +14036,387 @@ "type": "object", "required": [ "id", - "owner_id", - "mode", - "is_self", - "athlete_name", - "status", - "overall_score", + "email", + "role", "focus", - "review", - "thumbnail_url", + "profile", + "unit", + "private_videos", + "team_code", "created_at" ], - "title": "SessionSummary" - }, - "SocialAuthOut": { - "properties": { - "user": { - "$ref": "#/components/schemas/UserOut" - }, - "tokens": { - "$ref": "#/components/schemas/TokensOut" - }, - "is_new": { - "type": "boolean", - "title": "Is New" - } - }, - "type": "object", - "required": [ - "user", - "tokens", - "is_new" - ], - "title": "SocialAuthOut" + "title": "UserOut" }, - "SocialIn": { + "VoiceIn": { "properties": { - "provider": { + "kind": { "type": "string", - "enum": [ - "apple", - "google" - ], - "title": "Provider" + "const": "voice", + "title": "Kind" }, - "id_token": { + "upload_id": { "type": "string", - "maxLength": 8192, - "minLength": 1, - "title": "Id Token" + "format": "uuid", + "title": "Upload Id" }, - "role": { - "type": "string", - "enum": [ - "player", - "coach" - ], - "title": "Role", - "default": "player" + "seconds": { + "type": "number", + "maximum": 120.0, + "exclusiveMinimum": 0.0, + "title": "Seconds" } }, "additionalProperties": false, "type": "object", "required": [ - "provider", - "id_token" + "kind", + "upload_id", + "seconds" ], - "title": "SocialIn" + "title": "VoiceIn" }, - "SwingReport": { - "additionalProperties": false, + "VoiceMessageOut": { "properties": { - "schema_version": { - "const": "1.0", - "title": "Schema Version", - "type": "string" - }, - "analysis_id": { - "title": "Analysis Id", - "type": "string" - }, - "analysis_revision": { - "title": "Analysis Revision", - "type": "integer" + "id": { + "type": "string", + "format": "uuid", + "title": "Id" }, - "overall_score": { + "author_id": { "anyOf": [ { - "type": "integer" + "type": "string", + "format": "uuid" }, { "type": "null" } ], - "title": "Overall Score" + "title": "Author Id" }, - "overview": { - "$ref": "#/components/schemas/Overview" + "from": { + "type": "string", + "enum": [ + "player", + "coach" + ], + "title": "From" }, - "groups": { - "items": { - "$ref": "#/components/schemas/GroupReport" - }, - "title": "Groups", - "type": "array" + "at": { + "type": "string", + "format": "date-time", + "title": "At" }, - "focus_area": { + "kind": { + "type": "string", + "const": "voice", + "title": "Kind", + "default": "voice" + }, + "seconds": { + "type": "number", + "title": "Seconds" + }, + "audio": { "anyOf": [ { - "$ref": "#/components/schemas/FocusArea" + "$ref": "#/components/schemas/MediaRef" }, { "type": "null" } ] - }, - "measurements": { - "items": { - "$ref": "#/components/schemas/MeasurementReport" - }, - "title": "Measurements", - "type": "array" - }, - "data_quality": { - "items": { - "$ref": "#/components/schemas/DataQualityNote" - }, - "title": "Data Quality", - "type": "array" - }, - "meta": { - "$ref": "#/components/schemas/ReportMeta" } }, + "type": "object", "required": [ - "schema_version", - "analysis_id", - "analysis_revision", - "overall_score", - "overview", - "groups", - "focus_area", - "measurements", - "data_quality", - "meta" + "id", + "author_id", + "from", + "at", + "seconds", + "audio" ], - "title": "SwingReport", - "type": "object" + "title": "VoiceMessageOut" }, - "TeamCreate": { - "properties": { - "name": { - "type": "string", - "maxLength": 60, - "minLength": 2, - "title": "Name" - }, - "coach_name": { - "type": "string", - "maxLength": 60, - "minLength": 2, - "title": "Coach Name" - }, - "coaching": { - "type": "string", - "enum": [ - "h", - "p", - "both" - ], - "title": "Coaching" - } - }, - "additionalProperties": false, + "WebhookAck": { + "properties": {}, "type": "object", - "required": [ - "name", - "coach_name", - "coaching" - ], - "title": "TeamCreate" + "title": "WebhookAck" }, - "TeamOut": { + "WeeklyIn": { "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "code": { - "type": "string", - "title": "Code" - }, - "name": { - "type": "string", - "title": "Name" - }, - "coach_id": { - "type": "string", - "format": "uuid", - "title": "Coach Id" - }, - "coach_name": { - "type": "string", - "title": "Coach Name" - }, - "coaching": { - "type": "string", - "title": "Coaching" + "practice_days": { + "type": "integer", + "maximum": 7.0, + "minimum": 1.0, + "title": "Practice Days" }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" + "drill_sets": { + "type": "integer", + "maximum": 30.0, + "minimum": 1.0, + "title": "Drill Sets" } }, + "additionalProperties": false, "type": "object", "required": [ - "id", - "code", - "name", - "coach_id", - "coach_name", - "coaching", - "created_at" + "practice_days", + "drill_sets" ], - "title": "TeamOut", - "description": "The team shape every endpoint returns (GET /me, team create, lookup and join)." + "title": "WeeklyIn" }, - "TeamResponse": { + "WeeklyOut": { "properties": { - "team": { - "$ref": "#/components/schemas/TeamOut" + "practice_days": { + "type": "integer", + "title": "Practice Days" + }, + "drill_sets": { + "type": "integer", + "title": "Drill Sets" } }, "type": "object", "required": [ - "team" + "practice_days", + "drill_sets" ], - "title": "TeamResponse" + "title": "WeeklyOut" }, - "TeamSummaryOut": { + "app__modules__academy_org__schemas__GroupOut": { "properties": { - "code": { + "id": { "type": "string", - "title": "Code" + "format": "uuid", + "title": "Id" }, "name": { "type": "string", "title": "Name" }, - "coach_name": { + "focus": { "type": "string", - "title": "Coach Name" + "enum": [ + "Hitting", + "Pitching", + "Both" + ], + "title": "Focus" }, - "coaching": { - "type": "string", - "title": "Coaching" + "players": { + "type": "integer", + "title": "Players" + }, + "player_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Player Ids" + }, + "coaches": { + "items": { + "type": "string" + }, + "type": "array", + "title": "Coaches" + }, + "coach_ids": { + "items": { + "type": "string", + "format": "uuid" + }, + "type": "array", + "title": "Coach Ids" } }, "type": "object", "required": [ - "code", + "id", "name", - "coach_name", - "coaching" + "focus", + "players", + "player_ids", + "coaches", + "coach_ids" ], - "title": "TeamSummaryOut", - "description": "What a player sees before joining: no ids." + "title": "GroupOut" }, - "TeamSummaryResponse": { + "app__modules__catalog__schemas__GroupOut": { "properties": { - "team": { - "$ref": "#/components/schemas/TeamSummaryOut" + "group": { + "type": "string", + "title": "Group" + }, + "display_name": { + "type": "string", + "title": "Display Name" } }, "type": "object", "required": [ - "team" + "group", + "display_name" ], - "title": "TeamSummaryResponse" + "title": "GroupOut" }, - "TokensOut": { + "app__modules__reporting__schemas__ExportOut": { "properties": { - "access_token": { + "id": { "type": "string", - "title": "Access Token" + "format": "uuid", + "title": "Id" }, - "refresh_token": { + "status": { "type": "string", - "title": "Refresh Token" + "title": "Status" }, - "expires_in": { - "type": "integer", - "title": "Expires In" + "url": { + "type": "string", + "title": "Url" + }, + "expires_at": { + "type": "string", + "format": "date-time", + "title": "Expires At" + }, + "filename": { + "type": "string", + "title": "Filename" } }, "type": "object", "required": [ - "access_token", - "refresh_token", - "expires_in" + "id", + "status", + "url", + "expires_at", + "filename" ], - "title": "TokensOut" + "title": "ExportOut" }, - "UploadIn": { + "app__modules__sessions__schemas__SessionIn": { "properties": { - "kind": { + "video_upload_id": { "type": "string", - "enum": [ - "video", - "thumbnail" + "format": "uuid", + "title": "Video Upload Id" + }, + "thumbnail_upload_id": { + "anyOf": [ + { + "type": "string", + "format": "uuid" + }, + { + "type": "null" + } ], - "title": "Kind" + "title": "Thumbnail Upload Id" }, - "content_type": { + "mode": { "type": "string", - "maxLength": 40, - "minLength": 1, - "title": "Content Type" + "enum": [ + "h", + "p" + ], + "title": "Mode" }, - "size_bytes": { - "type": "integer", - "exclusiveMinimum": 0.0, - "title": "Size Bytes" + "is_self": { + "type": "boolean", + "title": "Is Self" }, - "duration_sec": { + "athlete": { "anyOf": [ { - "type": "number", - "exclusiveMinimum": 0.0 + "$ref": "#/components/schemas/AthleteIn" }, { "type": "null" } - ], + ] + }, + "duration_sec": { + "type": "number", + "exclusiveMinimum": 0.0, "title": "Duration Sec" + }, + "fps": { + "type": "integer", + "maximum": 240.0, + "minimum": 1.0, + "title": "Fps" + }, + "marks": { + "$ref": "#/components/schemas/MarksIn" } }, "additionalProperties": false, "type": "object", "required": [ - "kind", - "content_type", - "size_bytes" + "video_upload_id", + "mode", + "is_self", + "duration_sec", + "fps", + "marks" ], - "title": "UploadIn" + "title": "SessionIn" }, - "UploadOut": { + "app__modules__settings__schemas__ExportOut": { "properties": { - "upload_id": { + "id": { "type": "string", "format": "uuid", - "title": "Upload Id" + "title": "Id" }, - "url": { + "status": { "type": "string", - "title": "Url" - }, - "headers": { - "additionalProperties": { - "type": "string" - }, - "type": "object", - "title": "Headers" + "title": "Status" }, - "expires_at": { + "requested_at": { "type": "string", "format": "date-time", - "title": "Expires At" - } - }, - "type": "object", - "required": [ - "upload_id", - "url", - "headers", - "expires_at" - ], - "title": "UploadOut" - }, - "UserBody": { - "properties": { - "user": { - "$ref": "#/components/schemas/UserOut" + "title": "Requested At" + }, + "delivery": { + "type": "string", + "const": "account_email", + "title": "Delivery", + "default": "account_email" } }, "type": "object", "required": [ - "user" + "id", + "status", + "requested_at" ], - "title": "UserBody" + "title": "ExportOut" }, - "UserOut": { + "app__modules__threads__schemas__SessionIn": { "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "email": { - "type": "string", - "title": "Email" - }, - "role": { - "type": "string", - "title": "Role" - }, - "focus": { - "type": "string", - "title": "Focus" - }, - "profile": { - "$ref": "#/components/schemas/ProfileOut" - }, - "unit": { + "kind": { "type": "string", - "title": "Unit" - }, - "private_videos": { - "type": "boolean", - "title": "Private Videos" - }, - "team_code": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Team Code" + "const": "session", + "title": "Kind" }, - "created_at": { + "session_id": { "type": "string", - "format": "date-time", - "title": "Created At" + "format": "uuid", + "title": "Session Id" } }, + "additionalProperties": false, "type": "object", "required": [ - "id", - "email", - "role", - "focus", - "profile", - "unit", - "private_videos", - "team_code", - "created_at" + "kind", + "session_id" ], - "title": "UserOut" - }, - "WebhookAck": { - "properties": {}, - "type": "object", - "title": "WebhookAck" + "title": "SessionIn" }, "ErrorResponse": { "type": "object", @@ -5497,861 +14470,510 @@ "type": "string" }, "kind": { - "const": "reference_interval", - "title": "Kind", - "type": "string" - }, - "lower": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "title": "Lower" - }, - "upper": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "title": "Upper" - }, - "unit": { - "enum": [ - "deg", - "cm" - ], - "title": "Unit", - "type": "string" - }, - "source_reference": { - "minLength": 1, - "pattern": "\\S", - "title": "Source Reference", - "type": "string" - } - }, - "required": [ - "benchmark_id", - "version", - "kind", - "lower", - "upper", - "unit", - "source_reference" - ], - "title": "ApprovedBenchmark", - "type": "object" - }, - "Athlete": { - "additionalProperties": false, - "properties": { - "athlete_id": { - "minLength": 1, - "pattern": "\\S", - "title": "Athlete Id", - "type": "string" - }, - "batting_hand": { - "anyOf": [ - { - "enum": [ - "left", - "right" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Batting Hand" - }, - "lead_foot": { - "anyOf": [ - { - "enum": [ - "left", - "right" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Lead Foot" - }, - "age_years": { - "anyOf": [ - { - "minimum": 0, - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Age Years" - }, - "height_cm": { - "anyOf": [ - { - "exclusiveMinimum": 0, - "type": "number" - }, - { - "type": "null" - } - ], - "title": "Height Cm" - } - }, - "required": [ - "athlete_id", - "batting_hand", - "lead_foot", - "age_years", - "height_cm" - ], - "title": "Athlete", - "type": "object" - }, - "Events": { - "additionalProperties": false, - "properties": { - "stride_start": { - "$ref": "#/components/schemas/SwingEvent" - }, - "front_foot_down": { - "$ref": "#/components/schemas/SwingEvent" - }, - "contact": { - "$ref": "#/components/schemas/SwingEvent" - } - }, - "required": [ - "stride_start", - "front_foot_down", - "contact" - ], - "title": "Events", - "type": "object" - }, - "Measurement": { - "additionalProperties": false, - "properties": { - "metric_id": { - "enum": [ - "hip_shoulder_separation_at_foot_down", - "stride_relative_length", - "hip_shoulder_separation_at_contact" - ], - "title": "Metric Id", - "type": "string" - }, - "group": { - "enum": [ - "balance_load", - "stride", - "power_move", - "contact_follow_through" - ], - "title": "Group", - "type": "string" - }, - "value": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "title": "Value" - }, - "unit": { - "enum": [ - "deg", - "cm" - ], - "title": "Unit", - "type": "string" - }, - "event_id": { - "anyOf": [ - { - "enum": [ - "stride_start", - "front_foot_down", - "contact" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Event Id" - }, - "start_event_id": { - "anyOf": [ - { - "enum": [ - "stride_start", - "front_foot_down", - "contact" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "Start Event Id" - }, - "end_event_id": { - "anyOf": [ - { - "enum": [ - "stride_start", - "front_foot_down", - "contact" - ], - "type": "string" - }, - { - "type": "null" - } - ], - "default": null, - "title": "End Event Id" - }, - "reference": { - "enum": [ - "signed_horizontal_shoulder_minus_hip_heading", - "lead_ankle_displacement_relative_to_rear_ankle" - ], - "title": "Reference", - "type": "string" - }, - "status": { - "enum": [ - "available", - "limited", - "unavailable" - ], - "title": "Status", + "const": "reference_interval", + "title": "Kind", "type": "string" }, - "confidence": { + "lower": { "anyOf": [ { - "maximum": 1, - "minimum": 0, "type": "number" }, { "type": "null" } ], - "title": "Confidence" - }, - "uses_interpolated_input": { - "title": "Uses Interpolated Input", - "type": "boolean" - }, - "reasons": { - "items": { - "enum": [ - "contact_not_verified", - "contact_not_applicable", - "event_not_detected", - "event_timing_uncertain", - "required_event_unavailable", - "required_event_limited", - "lead_foot_unknown", - "required_landmarks_unusable", - "ground_plane_unknown", - "scale_is_model_estimated", - "scale_unknown", - "excessive_interpolation", - "occlusion_unresolved", - "temporal_inconsistency" - ], - "type": "string" - }, - "title": "Reasons", - "type": "array" + "title": "Lower" }, - "benchmark": { + "upper": { "anyOf": [ { - "$ref": "#/components/schemas/ApprovedBenchmark" + "type": "number" }, { "type": "null" } - ] - } - }, - "required": [ - "metric_id", - "group", - "value", - "unit", - "reference", - "status", - "confidence", - "uses_interpolated_input", - "reasons", - "benchmark" - ], - "title": "Measurement", - "type": "object" - }, - "SwingAnalysisPayload": { - "additionalProperties": false, - "properties": { - "schema_version": { - "const": "1.0", - "title": "Schema Version", - "type": "string" + ], + "title": "Upper" }, - "analysis_id": { - "minLength": 1, - "pattern": "\\S", - "title": "Analysis Id", + "unit": { + "enum": [ + "deg", + "cm" + ], + "title": "Unit", "type": "string" }, - "analysis_revision": { - "minimum": 1, - "title": "Analysis Revision", - "type": "integer" - }, - "swing_id": { + "source_reference": { "minLength": 1, "pattern": "\\S", - "title": "Swing Id", - "type": "string" - }, - "status": { - "const": "completed", - "title": "Status", - "type": "string" - }, - "athlete": { - "$ref": "#/components/schemas/Athlete" - }, - "context": { - "$ref": "#/components/schemas/SwingContext" - }, - "measurement_definitions_version": { - "const": "1.0", - "title": "Measurement Definitions Version", + "title": "Source Reference", "type": "string" - }, - "events": { - "$ref": "#/components/schemas/Events" - }, - "measurements": { - "items": { - "$ref": "#/components/schemas/Measurement" - }, - "minItems": 1, - "title": "Measurements", - "type": "array" } }, "required": [ - "schema_version", - "analysis_id", - "analysis_revision", - "swing_id", - "status", - "athlete", - "context", - "measurement_definitions_version", - "events", - "measurements" + "benchmark_id", + "version", + "kind", + "lower", + "upper", + "unit", + "source_reference" ], - "title": "SwingAnalysisPayload", + "title": "ApprovedBenchmark", "type": "object" }, - "SwingContext": { + "Athlete": { "additionalProperties": false, "properties": { - "sport": { - "const": "baseball", - "title": "Sport", + "athlete_id": { + "minLength": 1, + "pattern": "\\S", + "title": "Athlete Id", "type": "string" }, - "practice_type": { - "enum": [ - "tee", - "front_toss", - "side_toss", - "pitching_machine", - "live_pitching", - "game", - "dry_swing", - "unknown" - ], - "title": "Practice Type", - "type": "string" - } - }, - "required": [ - "sport", - "practice_type" - ], - "title": "SwingContext", - "type": "object" - }, - "SwingEvent": { - "additionalProperties": false, - "properties": { - "status": { - "enum": [ - "available", - "limited", - "unavailable" + "batting_hand": { + "anyOf": [ + { + "enum": [ + "left", + "right" + ], + "type": "string" + }, + { + "type": "null" + } ], - "title": "Status", - "type": "string" + "title": "Batting Hand" }, - "video_time_s": { + "lead_foot": { "anyOf": [ { - "type": "number" + "enum": [ + "left", + "right" + ], + "type": "string" }, { "type": "null" } ], - "title": "Video Time S" + "title": "Lead Foot" }, - "capture_time_s": { + "age_years": { "anyOf": [ { - "type": "number" + "minimum": 0, + "type": "integer" }, { "type": "null" } ], - "title": "Capture Time S" + "title": "Age Years" }, - "source": { + "height_cm": { "anyOf": [ { - "enum": [ - "manual_review", - "pose_estimated", - "bat_ball_detector" - ], - "type": "string" + "exclusiveMinimum": 0, + "type": "number" }, { "type": "null" } ], - "title": "Source" + "title": "Height Cm" + } + }, + "required": [ + "athlete_id", + "batting_hand", + "lead_foot", + "age_years", + "height_cm" + ], + "title": "Athlete", + "type": "object" + }, + "Events": { + "additionalProperties": false, + "properties": { + "stride_start": { + "$ref": "#/components/schemas/SwingEvent" }, - "reasons": { - "items": { - "enum": [ - "contact_not_verified", - "contact_not_applicable", - "event_not_detected", - "event_timing_uncertain", - "required_event_unavailable", - "required_event_limited", - "lead_foot_unknown", - "required_landmarks_unusable", - "ground_plane_unknown", - "scale_is_model_estimated", - "scale_unknown", - "excessive_interpolation", - "occlusion_unresolved", - "temporal_inconsistency" - ], - "type": "string" - }, - "title": "Reasons", - "type": "array" + "front_foot_down": { + "$ref": "#/components/schemas/SwingEvent" + }, + "contact": { + "$ref": "#/components/schemas/SwingEvent" } }, "required": [ - "status", - "video_time_s", - "capture_time_s", - "source" + "stride_start", + "front_foot_down", + "contact" ], - "title": "SwingEvent", + "title": "Events", "type": "object" }, - "AuditLogSummary": { + "Measurement": { + "additionalProperties": false, "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" - }, - "started_at": { - "type": "string", - "format": "date-time", - "title": "Started At" - }, - "request_id": { - "type": "string", - "title": "Request Id" - }, - "method": { - "type": "string", - "title": "Method" + "metric_id": { + "enum": [ + "hip_shoulder_separation_at_foot_down", + "stride_relative_length", + "hip_shoulder_separation_at_contact" + ], + "title": "Metric Id", + "type": "string" }, - "path": { - "type": "string", - "title": "Path" + "group": { + "enum": [ + "balance_load", + "stride", + "power_move", + "contact_follow_through" + ], + "title": "Group", + "type": "string" }, - "route": { + "value": { "anyOf": [ { - "type": "string" + "type": "number" }, { "type": "null" } ], - "title": "Route" - }, - "status_code": { - "type": "integer", - "title": "Status Code" + "title": "Value" }, - "duration_ms": { - "type": "number", - "title": "Duration Ms" + "unit": { + "enum": [ + "deg", + "cm" + ], + "title": "Unit", + "type": "string" }, - "account_id": { + "event_id": { "anyOf": [ { - "type": "string", - "format": "uuid" + "enum": [ + "stride_start", + "front_foot_down", + "contact" + ], + "type": "string" }, { "type": "null" } ], - "title": "Account Id" + "default": null, + "title": "Event Id" }, - "session_id": { + "start_event_id": { "anyOf": [ { - "type": "string", - "format": "uuid" + "enum": [ + "stride_start", + "front_foot_down", + "contact" + ], + "type": "string" }, { "type": "null" } ], - "title": "Session Id" + "default": null, + "title": "Start Event Id" }, - "analysis_id": { + "end_event_id": { "anyOf": [ { + "enum": [ + "stride_start", + "front_foot_down", + "contact" + ], "type": "string" }, { "type": "null" } ], - "title": "Analysis Id" + "default": null, + "title": "End Event Id" }, - "analysis_revision": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } + "reference": { + "enum": [ + "signed_horizontal_shoulder_minus_hip_heading", + "lead_ankle_displacement_relative_to_rear_ankle" ], - "title": "Analysis Revision" + "title": "Reference", + "type": "string" }, - "error_code": { + "status": { + "enum": [ + "available", + "limited", + "unavailable" + ], + "title": "Status", + "type": "string" + }, + "confidence": { "anyOf": [ { - "type": "string" + "maximum": 1, + "minimum": 0, + "type": "number" }, { "type": "null" } ], - "title": "Error Code" + "title": "Confidence" }, - "exception_type": { + "uses_interpolated_input": { + "title": "Uses Interpolated Input", + "type": "boolean" + }, + "reasons": { + "items": { + "enum": [ + "contact_not_verified", + "contact_not_applicable", + "event_not_detected", + "event_timing_uncertain", + "required_event_unavailable", + "required_event_limited", + "lead_foot_unknown", + "required_landmarks_unusable", + "ground_plane_unknown", + "scale_is_model_estimated", + "scale_unknown", + "excessive_interpolation", + "occlusion_unresolved", + "temporal_inconsistency" + ], + "type": "string" + }, + "title": "Reasons", + "type": "array" + }, + "benchmark": { "anyOf": [ { - "type": "string" + "$ref": "#/components/schemas/ApprovedBenchmark" }, { "type": "null" } - ], - "title": "Exception Type" - }, - "response_complete": { - "type": "boolean", - "title": "Response Complete" - }, - "service_version": { - "type": "string", - "title": "Service Version" + ] } }, - "type": "object", "required": [ - "id", - "created_at", - "started_at", - "request_id", - "method", - "path", - "route", - "status_code", - "duration_ms", - "account_id", - "session_id", - "analysis_id", - "analysis_revision", - "error_code", - "exception_type", - "response_complete", - "service_version" + "metric_id", + "group", + "value", + "unit", + "reference", + "status", + "confidence", + "uses_interpolated_input", + "reasons", + "benchmark" ], - "title": "AuditLogSummary" + "title": "Measurement", + "type": "object" }, - "AuditLogDetail": { + "SwingAnalysisPayload": { + "additionalProperties": false, "properties": { - "id": { - "type": "string", - "format": "uuid", - "title": "Id" - }, - "created_at": { - "type": "string", - "format": "date-time", - "title": "Created At" + "schema_version": { + "const": "1.0", + "title": "Schema Version", + "type": "string" }, - "started_at": { - "type": "string", - "format": "date-time", - "title": "Started At" + "analysis_id": { + "minLength": 1, + "pattern": "\\S", + "title": "Analysis Id", + "type": "string" }, - "request_id": { - "type": "string", - "title": "Request Id" + "analysis_revision": { + "minimum": 1, + "title": "Analysis Revision", + "type": "integer" }, - "method": { - "type": "string", - "title": "Method" + "swing_id": { + "minLength": 1, + "pattern": "\\S", + "title": "Swing Id", + "type": "string" }, - "path": { - "type": "string", - "title": "Path" + "status": { + "const": "completed", + "title": "Status", + "type": "string" }, - "route": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Route" + "athlete": { + "$ref": "#/components/schemas/Athlete" }, - "status_code": { - "type": "integer", - "title": "Status Code" + "context": { + "$ref": "#/components/schemas/SwingContext" }, - "duration_ms": { - "type": "number", - "title": "Duration Ms" + "measurement_definitions_version": { + "const": "1.0", + "title": "Measurement Definitions Version", + "type": "string" }, - "account_id": { - "anyOf": [ - { - "type": "string", - "format": "uuid" - }, - { - "type": "null" - } - ], - "title": "Account Id" + "events": { + "$ref": "#/components/schemas/Events" }, - "session_id": { - "anyOf": [ - { - "type": "string", - "format": "uuid" - }, - { - "type": "null" - } - ], - "title": "Session Id" + "measurements": { + "items": { + "$ref": "#/components/schemas/Measurement" + }, + "minItems": 1, + "title": "Measurements", + "type": "array" + } + }, + "required": [ + "schema_version", + "analysis_id", + "analysis_revision", + "swing_id", + "status", + "athlete", + "context", + "measurement_definitions_version", + "events", + "measurements" + ], + "title": "SwingAnalysisPayload", + "type": "object" + }, + "SwingContext": { + "additionalProperties": false, + "properties": { + "sport": { + "const": "baseball", + "title": "Sport", + "type": "string" }, - "analysis_id": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } + "practice_type": { + "enum": [ + "tee", + "front_toss", + "side_toss", + "pitching_machine", + "live_pitching", + "game", + "dry_swing", + "unknown" ], - "title": "Analysis Id" + "title": "Practice Type", + "type": "string" + } + }, + "required": [ + "sport", + "practice_type" + ], + "title": "SwingContext", + "type": "object" + }, + "SwingEvent": { + "additionalProperties": false, + "properties": { + "status": { + "enum": [ + "available", + "limited", + "unavailable" + ], + "title": "Status", + "type": "string" }, - "analysis_revision": { + "video_time_s": { "anyOf": [ { - "type": "integer" + "type": "number" }, { "type": "null" } ], - "title": "Analysis Revision" + "title": "Video Time S" }, - "error_code": { + "capture_time_s": { "anyOf": [ { - "type": "string" + "type": "number" }, { "type": "null" } ], - "title": "Error Code" + "title": "Capture Time S" }, - "exception_type": { + "source": { "anyOf": [ { + "enum": [ + "manual_review", + "pose_estimated", + "bat_ball_detector" + ], "type": "string" }, { "type": "null" } ], - "title": "Exception Type" - }, - "response_complete": { - "type": "boolean", - "title": "Response Complete" - }, - "service_version": { - "type": "string", - "title": "Service Version" - }, - "request_headers": { - "additionalProperties": true, - "type": "object", - "title": "Request Headers" - }, - "query_params": { - "additionalProperties": true, - "type": "object", - "title": "Query Params" - }, - "request_payload": { - "additionalProperties": true, - "type": "object", - "title": "Request Payload" - }, - "response_headers": { - "additionalProperties": true, - "type": "object", - "title": "Response Headers" + "title": "Source" }, - "response_payload": { - "additionalProperties": true, - "type": "object", - "title": "Response Payload" - } - }, - "type": "object", - "required": [ - "id", - "created_at", - "started_at", - "request_id", - "method", - "path", - "route", - "status_code", - "duration_ms", - "account_id", - "session_id", - "analysis_id", - "analysis_revision", - "error_code", - "exception_type", - "response_complete", - "service_version", - "request_headers", - "query_params", - "request_payload", - "response_headers", - "response_payload" - ], - "title": "AuditLogDetail" - }, - "Page_AuditLogSummary_": { - "properties": { - "items": { + "reasons": { "items": { - "$ref": "#/components/schemas/AuditLogSummary" + "enum": [ + "contact_not_verified", + "contact_not_applicable", + "event_not_detected", + "event_timing_uncertain", + "required_event_unavailable", + "required_event_limited", + "lead_foot_unknown", + "required_landmarks_unusable", + "ground_plane_unknown", + "scale_is_model_estimated", + "scale_unknown", + "excessive_interpolation", + "occlusion_unresolved", + "temporal_inconsistency" + ], + "type": "string" }, - "type": "array", - "title": "Items" - }, - "next_cursor": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Next Cursor" + "title": "Reasons", + "type": "array" } }, - "type": "object", "required": [ - "items" + "status", + "video_time_s", + "capture_time_s", + "source" ], - "title": "Page[AuditLogSummary]" + "title": "SwingEvent", + "type": "object" } } } -} +} \ No newline at end of file diff --git a/backend/tests/integration/test_swing_reports.py b/backend/tests/integration/test_swing_reports.py index 5a28a1797d1a09bb1392fbada565ac2992d01940..019864512ce1182379fb435e7a5c718c5ee30034 100644 --- a/backend/tests/integration/test_swing_reports.py +++ b/backend/tests/integration/test_swing_reports.py @@ -1,9 +1,11 @@ """H1: POST /v1/sessions/{id}/swing-report.""" import copy +import json import uuid from datetime import UTC, datetime from decimal import Decimal +from pathlib import Path import pytest from ai_coach.swing_report import build_report @@ -147,6 +149,39 @@ async def test_higher_revision_rebuilds_and_replaces(client, builds): assert len(builds) == 2 +async def test_v11_report_revision_updates_exact_source_marks(client): + owner, headers = await make_account() + sid = await make_session(owner) + p = json.loads((Path(__file__).resolve().parents[3] / "docs/motion-coach-payload-v1.1.example.json").read_text()) + first = await client.post(url(sid), json=p, headers=headers) + assert first.status_code == 200, first.text + assert all(group["score"] is not None for group in first.json()["groups"]) + row = await load_session(sid) + assert row.marks == {"stride_start_frame": 3, "stride_end_frame": 10, "contact_frame": 20, + "contact_offset": 0, "contact_source": "manual"} + p["analysis_revision"] = 2 + p["events"]["contact"].update(source_frame_index=21, video_time_s=0.7, capture_time_s=0.7) + p["events"]["follow_through"].update(source_frame_index=24, video_time_s=0.8, capture_time_s=0.8) + revised = await client.post(url(sid), json=p, headers=headers) + assert revised.status_code == 200, revised.text + row = await load_session(sid) + assert row.marks["contact_frame"] == 21 and row.measurement_payload == p + assert row.report == revised.json() and row.analysis_revision == 2 + + +async def test_legacy_report_preserves_marks_without_guessing_frames_from_times(client): + owner, headers = await make_account() + sid = await make_session(owner) + original = {"contact_frame": 75, "contact_offset": 0, "contact_source": "manual"} + async with get_session_factory()() as db: + row = await db.get(SwingSession, sid) + row.marks = original + await db.commit() + response = await client.post(url(sid), json=PAYLOAD, headers=headers) + assert response.status_code == 200, response.text + assert (await load_session(sid)).marks == original + + async def test_lower_revision_is_stale(client): owner, headers = await make_account() sid = await make_session(owner) @@ -175,7 +210,7 @@ async def test_invalid_payload(client): assert response.status_code == 422 error = response.json()["error"] assert error["code"] == "INVALID_PAYLOAD" - assert error["message"] == "The payload does not follow swing analysis contract 1.0." + assert error["message"] == "The payload does not follow swing analysis contract 1.0 or 1.1." assert error["fields"] == { "measurements[1].reasons": "A limited result needs at least one reason code.", "events.stride_start.video_time_s": "Must be before front_foot_down.", @@ -279,6 +314,8 @@ async def test_payload_batting_hand_wins(client): sid = await make_session(owner, athlete={**ATHLETE, "bats": "L"}) response = await client.post(url(sid), json=PAYLOAD, headers=headers) assert response.json()["measurements"][0]["benchmark"]["benchmark_id"].endswith(".right.college") + assert "batting_hand_conflict" in {n["code"] for n in response.json()["data_quality"]} + assert response.json()["focus_area"]["kind"] == "general" async def test_missing_gemini_key_is_an_error_not_a_template_report(client, monkeypatch): diff --git a/baseball_batting/api.py b/baseball_batting/api.py index bac9ba4e5a772691ef93e114de62ffe73727229c..b0780b646ff8d497dff3fd729e611ce99b1f8293 100644 --- a/baseball_batting/api.py +++ b/baseball_batting/api.py @@ -78,7 +78,7 @@ def create_app(settings=None, service=None): service.start() try: yield finally: service.stop() - app = FastAPI(title="Baseball Swing Engine and Coach", version="1.18.0", lifespan=lifespan, + app = FastAPI(title="Baseball Swing Engine and Coach", version="1.19.0", lifespan=lifespan, description="GPU batting/load timing with separate bat keypoint and baseball models. Single-view visual contact; physical miss/shift require synchronized calibrated views. Accuracy validation pending.") app.state.service = service app.add_middleware(UploadGuard, settings=settings, service=service) diff --git a/baseball_batting/coach_geometry.py b/baseball_batting/coach_geometry.py new file mode 100644 index 0000000000000000000000000000000000000000..cb6c3370be7104b374d560792b24c623791e3bee --- /dev/null +++ b/baseball_batting/coach_geometry.py @@ -0,0 +1,57 @@ +"""Contract 1.1 geometry shared by video export and reference-data calibration. + +Inputs are anatomical joint centres in any fixed orthonormal frame, in metres. +These are kinematic descriptions, not measurements of force or energy transfer. +""" +import numpy as np + + +EXTENDED_METRICS = ( + 'torso_inclination_at_stride_start', + 'hip_shoulder_separation_at_stride_start', + 'pelvis_rotation_to_contact', + 'lead_knee_extension_to_contact', + 'torso_inclination_at_contact', + 'shoulder_rotation_after_contact', +) +FOLLOW_THROUGH_SECONDS = .1 + + +def inclination(hips, shoulders, up): + torso = np.asarray(shoulders) - np.asarray(hips) + vertical = torso @ np.asarray(up) + horizontal = torso - vertical[..., None] * np.asarray(up) + angle = np.degrees(np.arctan2(np.linalg.norm(horizontal, axis=-1), vertical)) + return np.where(vertical > .05, angle, np.nan) + + +def knee_angle(hip, knee, ankle): + a, b = np.asarray(hip) - knee, np.asarray(ankle) - knee + denominator = np.linalg.norm(a, axis=-1) * np.linalg.norm(b, axis=-1) + cosine = np.divide(np.sum(a * b, axis=-1), denominator, + out=np.full_like(denominator, np.nan), where=denominator > 1e-8) + return np.degrees(np.arccos(np.clip(cosine, -1, 1))) + + +def rotation_amount(headings, start, end): + """Magnitude of net unwrapped horizontal rotation; never a peak-speed proxy.""" + if start is None or end is None or start >= end: + return np.nan + values = np.asarray(headings)[start:end + 1] + if not np.isfinite(values).all(): + return np.nan + return float(abs(np.degrees(np.unwrap(np.radians(values))[-1] - np.radians(values[0])))) + + +def follow_through_frame(times, contact, end): + """Nearest original sample to contact + 100 ms; a complete interval is required.""" + if contact is None: + return None + times = np.asarray(times, float) + if not np.isfinite(times[contact:end + 1]).all() or np.any(np.diff(times[contact:end + 1]) <= 0): + return None + target = times[contact] + FOLLOW_THROUGH_SECONDS + if times[end] < target: + return None + i = int(np.argmin(np.abs(times[contact:end + 1] - target))) + contact + return i if i > contact else None diff --git a/baseball_batting/motion_api.py b/baseball_batting/motion_api.py index 266d58311a544a964939a7a28088e7bb9aa5723f..f128592e81e95d3c68a5435ddf3ced80be0e17aa 100644 --- a/baseball_batting/motion_api.py +++ b/baseball_batting/motion_api.py @@ -5,7 +5,7 @@ from pathlib import Path import shutil from typing import Annotated from fastapi import Depends, File, Form, HTTPException, Request, UploadFile -from fastapi.responses import JSONResponse +from fastapi.responses import JSONResponse, Response from pydantic import ValidationError from .motion_contract import MotionInput, MotionManifest, MotionFrame, ProjectionFrame, RevisionRequest, ADAPTER_VERSION from .sam_motion import MHR @@ -193,12 +193,13 @@ def register(app,service,authenticated): 'detail':'Submit athlete information and single_swing=true, or create a revision with those options'}) handle,_=open_verified_media(artifact_path(directory,asset),asset.sha256,asset.size_bytes) try: - with handle:payload=MotionCoachPayload.model_validate(json.load(handle)) + with handle:raw_payload=handle.read() + payload=MotionCoachPayload.model_validate_json(raw_payload) except (ValueError,ValidationError): raise HTTPException(500,'Stored coach payload is invalid') from None if payload.analysis_id!=manifest.analysis_id or payload.analysis_revision!=manifest.analysis_revision: raise HTTPException(500,'Coach payload differs from the analysis revision') - return JSONResponse(payload.model_dump(mode='json'),headers={'Cache-Control':'no-store'}) + return Response(raw_payload,media_type='application/json',headers={'Cache-Control':'no-store'}) @app.get(PREFIX+'/{identifier}/artifacts/{name}',dependencies=[Depends(authenticated)]) @app.head(PREFIX+'/{identifier}/artifacts/{name}',dependencies=[Depends(authenticated)],include_in_schema=False) diff --git a/baseball_batting/motion_coach.py b/baseball_batting/motion_coach.py index e90c943bfd08eff706a1a2f8dd64babaf4bef43c..e034647f5b77ba772fc48e5b925004d618e17c1a 100644 --- a/baseball_batting/motion_coach.py +++ b/baseball_batting/motion_coach.py @@ -1,11 +1,12 @@ -"""Export the coach's three metrics from the same corrected motion as replay. +"""Export versioned coach measurements from the same corrected motion as replay. The selected source frames are manual review, not automatic event detections. They identify sampled video moments, not measured ground force or subframe contact. """ import numpy as np from .motion_coach_contract import (CoachEvents, CoachEvent, MotionCoachPayload, - SeparationAtFootDown, RelativeStride, SeparationAtContact) + SeparationAtFootDown, RelativeStride, SeparationAtContact, ExtendedMeasurement, ValueInterval) +from .coach_geometry import follow_through_frame, inclination, knee_angle, rotation_amount from .sam_measurements import frame_curves, wrap180 from .sam_motion import MHR @@ -18,7 +19,7 @@ def build_coach_payload(options, lineage, corrected, video_times, capture_times, if options.athlete is None: return None if not options.single_swing or len(contexts) > 1: - raise ValueError('Coach contract 1.0 requires one swing per video') + raise ValueError('The coach contract requires one swing per video') n = len(video_times) options.validate_frame_count(n) window = options.windows[0] if options.windows else None @@ -28,18 +29,22 @@ def build_coach_payload(options, lineage, corrected, video_times, capture_times, lead = options.lead_foot or {'right': 'left', 'left': 'right'}.get(options.handedness) athlete = options.athlete.model_copy(update={'batting_hand': options.handedness, 'lead_foot': lead}) - def event(index, missing_reason): + def event(index, missing_reason, source='manual_review'): if index is None: return CoachEvent(status='unavailable', video_time_s=None, capture_time_s=None, source=None, reasons=[missing_reason]) return CoachEvent(status='limited', video_time_s=float(video_times[index]), capture_time_s=float(capture_times[index]) if np.isfinite(capture_times[index]) else None, - source='manual_review', reasons=['event_timing_uncertain']) + source=source, source_frame_index=index, reasons=['event_timing_uncertain']) + + finish = follow_through_frame(capture_times, contact, window.end_frame if window else n - 1) + finish_reason = 'capture_time_unknown' if not np.isfinite(capture_times).all() else 'follow_through_not_recorded' events = CoachEvents(stride_start=event(stride_start, 'event_not_detected'), front_foot_down=event(landing, 'event_not_detected'), contact=event(contact, 'contact_not_applicable' if options.context.practice_type == 'dry_swing' - else 'contact_not_verified')) + else 'contact_not_verified'), + follow_through=event(finish, finish_reason, 'derived_from_contact')) if contexts: context = contexts[0] curves = context['curves'] @@ -76,7 +81,7 @@ def build_coach_payload(options, lineage, corrected, video_times, capture_times, if missing: return model(value=None, status='unavailable', confidence=None, uses_interpolated_input=interpolated, reasons=missing) - reasons = list(dict.fromkeys([*timing, *warnings])) + reasons = list(dict.fromkeys([*timing, *warnings, 'model_accuracy_unvalidated'])) return model(value=value, status='limited' if reasons else 'available', confidence=None, uses_interpolated_input=interpolated, reasons=reasons) @@ -95,8 +100,32 @@ def build_coach_payload(options, lineage, corrected, video_times, capture_times, missing.append('required_landmarks_unusable') return result(model, value, missing, selected_event.reasons, interpolated, warnings) - foot_angle = separation(SeparationAtFootDown, landing, events.front_foot_down) - contact_angle = separation(SeparationAtContact, contact, events.contact) + def add_interval(metric, evaluate, indices, names): + if metric.value is None or any(i is None for i in indices): + return metric + from itertools import product + lo, hi = (window.start_frame, window.end_frame) if window else (0, n - 1) + values = [metric.value] + for ids in product(*(range(max(lo, i - 1), min(hi, i + 1) + 1) for i in indices)): + if len(ids) > 1 and ids[0] >= ids[-1]: + continue + checked = list(range(ids[0], ids[-1] + 1)) if len(ids) > 1 else ids + if quality(checked, names)[1]: + return metric # A partial neighborhood cannot bound event sensitivity. + value = evaluate(*ids) + if not np.isfinite(value): + return metric + values.append(float(value)) + # A wrapped angle can straddle -180/+180; a linear interval would be misleading. + if metric.reference == 'signed_horizontal_shoulder_minus_hip_heading' and max(values) - min(values) > 180: + return metric + metric.value_interval = ValueInterval(lower=min(values), upper=max(values)) + return metric + + sep = lambda i: curves['hip_shoulder_separation_deg'][i] + torso_names = ['left_hip', 'right_hip', 'left_shoulder', 'right_shoulder'] + foot_angle = add_interval(separation(SeparationAtFootDown, landing, events.front_foot_down), sep, [landing], torso_names) + contact_angle = add_interval(separation(SeparationAtContact, contact, events.contact), sep, [contact], torso_names) interpolated, missing, warnings = quality([stride_start, landing], ['left_hip', 'right_hip', 'left_ankle', 'right_ankle']) timing = [] @@ -126,6 +155,67 @@ def build_coach_payload(options, lineage, corrected, video_times, capture_times, else: missing.append('required_landmarks_unusable') stride_metric = result(RelativeStride, stride, missing, timing, interpolated, warnings) + if oriented is not None and lead is not None: + li, ri = (MHR['left_ankle'], MHR['right_ankle']) if lead == 'left' else (MHR['right_ankle'], MHR['left_ankle']) + def stride_value(a, b): + return 100 * np.linalg.norm(((oriented[b, li] - oriented[b, ri]) - + (oriented[a, li] - oriented[a, ri]))[:2]) + add_interval(stride_metric, stride_value, [stride_start, landing], + ['left_hip', 'right_hip', 'left_ankle', 'right_ankle']) + + hip_names = ['left_hip', 'right_hip'] + torso_names = [*hip_names, 'left_shoulder', 'right_shoulder'] + lean = np.full(n, np.nan) + knee = np.full(n, np.nan) + if oriented is not None: + lean = inclination((oriented[:, 9] + oriented[:, 10]) / 2, + (oriented[:, 5] + oriented[:, 6]) / 2, [0, 0, 1]) + if lead is not None: + knee = knee_angle(oriented[:, MHR[lead + '_hip']], oriented[:, MHR[lead + '_knee']], + oriented[:, MHR[lead + '_ankle']]) + event_map = {'stride_start': events.stride_start, 'front_foot_down': events.front_foot_down, + 'contact': events.contact, 'follow_through': events.follow_through} + def extra(metric_id, group, reference_name, names, ids, event_ids, evaluate, *, lead_required=False): + checked = list(range(ids[0], ids[-1] + 1)) if len(ids) == 2 and all(i is not None for i in ids) else ids + interp, absent, warns = quality(checked, names) + event_reasons = [] + for key in event_ids: + ev = event_map[key] + if ev.status == 'unavailable': + absent += ['required_event_unavailable', *ev.reasons] + else: + event_reasons += ev.reasons + if lead_required and lead is None: + absent.append('lead_foot_unknown') + value = evaluate(*ids) if not absent else np.nan + if not absent and not np.isfinite(value): + absent.append('required_landmarks_unusable') + common = dict(metric_id=metric_id, group=group, reference=reference_name) + common.update({'event_id': event_ids[0]} if len(event_ids) == 1 else + {'start_event_id': event_ids[0], 'end_event_id': event_ids[-1]}) + rounded = round(float(value), 3) if np.isfinite(value) else None + if rounded is not None and reference_name == 'signed_horizontal_shoulder_minus_hip_heading': + rounded = float(wrap180(rounded)) + row = result(lambda **fields: ExtendedMeasurement(**common, **fields), rounded, + absent, event_reasons, interp, warns) + return add_interval(row, evaluate, ids, names) + extended = [ + extra('torso_inclination_at_stride_start', 'balance_load', 'torso_angle_from_vertical', + torso_names, [stride_start], ['stride_start'], lambda i: lean[i]), + extra('hip_shoulder_separation_at_stride_start', 'balance_load', + 'signed_horizontal_shoulder_minus_hip_heading', torso_names, [stride_start], ['stride_start'], sep), + extra('pelvis_rotation_to_contact', 'power_move', 'absolute_net_horizontal_rotation', + hip_names, [landing, contact], ['front_foot_down', 'contact'], + lambda a, b: rotation_amount(curves['hip_heading_deg'], a, b)), + extra('lead_knee_extension_to_contact', 'power_move', 'change_in_3d_lead_knee_angle', + [lead + '_' + part for part in ('hip', 'knee', 'ankle')] if lead else hip_names, + [landing, contact], ['front_foot_down', 'contact'], lambda a, b: knee[b] - knee[a], lead_required=True), + extra('torso_inclination_at_contact', 'contact_follow_through', 'torso_angle_from_vertical', + torso_names, [contact], ['contact'], lambda i: lean[i]), + extra('shoulder_rotation_after_contact', 'contact_follow_through', 'absolute_net_horizontal_rotation', + ['left_shoulder', 'right_shoulder'], [contact, finish], ['contact', 'follow_through'], + lambda a, b: rotation_amount(curves['shoulder_heading_deg'], a, b)), + ] return MotionCoachPayload(analysis_id=lineage['analysis_id'], analysis_revision=lineage['analysis_revision'], swing_id=swing_identity(options, lineage['analysis_id']), athlete=athlete, context=options.context, - events=events, measurements=[foot_angle, stride_metric, contact_angle]) + events=events, measurements=[foot_angle, stride_metric, contact_angle, *extended]) diff --git a/baseball_batting/motion_coach_contract.py b/baseball_batting/motion_coach_contract.py index 55db28da4732bd876bf15d077fe8eecc149ab68e..e55b7c58650cba24f422ce68c11bf260ea492944 100644 --- a/baseball_batting/motion_coach_contract.py +++ b/baseball_batting/motion_coach_contract.py @@ -1,7 +1,8 @@ -"""Coach contract 1.0: exactly three measurements for one recorded swing.""" +"""Versioned coach measurements for one recorded swing; old stored payloads remain readable.""" from typing import Literal from pydantic import Field, model_validator from .sam_batting_contract import Strict +from .coach_geometry import EXTENDED_METRICS class CoachAthlete(Strict): @@ -22,20 +23,22 @@ Reason = Literal['contact_not_verified', 'contact_not_applicable', 'event_not_de 'event_timing_uncertain', 'required_event_unavailable', 'required_event_limited', 'lead_foot_unknown', 'required_landmarks_unusable', 'ground_plane_unknown', 'scale_is_model_estimated', 'scale_unknown', 'excessive_interpolation', - 'occlusion_unresolved', 'temporal_inconsistency'] + 'occlusion_unresolved', 'temporal_inconsistency', 'capture_time_unknown', + 'follow_through_not_recorded', 'model_accuracy_unvalidated'] class CoachEvent(Strict): video_time_s: float | None = Field(ge=0) capture_time_s: float | None = Field(ge=0) status: Literal['available', 'limited', 'unavailable'] - source: Literal['manual_review', 'pose_estimated', 'bat_ball_detector'] | None + source: Literal['manual_review', 'pose_estimated', 'bat_ball_detector', 'derived_from_contact'] | None reasons: list[Reason] + source_frame_index: int | None = Field(default=None, ge=0, strict=True) @model_validator(mode='after') def consistent(self): if self.status == 'unavailable': - if any(v is not None for v in (self.video_time_s, self.capture_time_s, self.source)): + if any(v is not None for v in (self.video_time_s, self.capture_time_s, self.source, self.source_frame_index)): raise ValueError('Unavailable events must have null times and source') elif self.video_time_s is None or self.source is None: raise ValueError('Usable events need video time and source') @@ -48,6 +51,19 @@ class CoachEvents(Strict): stride_start: CoachEvent front_foot_down: CoachEvent contact: CoachEvent + follow_through: CoachEvent | None = None + + +class ValueInterval(Strict): + lower: float + upper: float + source: Literal['adjacent_event_frames'] = 'adjacent_event_frames' + + @model_validator(mode='after') + def ordered(self): + if self.lower > self.upper: + raise ValueError('Measurement interval must be ordered') + return self class CoachMeasurement(Strict): @@ -57,6 +73,7 @@ class CoachMeasurement(Strict): uses_interpolated_input: bool reasons: list[Reason] benchmark: None = None + value_interval: ValueInterval | None = None @model_validator(mode='after') def consistent(self): @@ -66,6 +83,9 @@ class CoachMeasurement(Strict): raise ValueError('Unavailable measurements have null confidence') if (self.status == 'available') != (not self.reasons): raise ValueError('Only available measurements have an empty reasons list') + if self.value_interval is not None and (self.value is None or not + self.value_interval.lower <= self.value <= self.value_interval.upper): + raise ValueError('The event sensitivity interval must include the measurement value') return self @@ -97,9 +117,26 @@ class SeparationAtContact(CoachMeasurement): value: float | None = Field(ge=-180, lt=180) +class ExtendedMeasurement(CoachMeasurement): + metric_id: Literal['torso_inclination_at_stride_start', 'hip_shoulder_separation_at_stride_start', + 'pelvis_rotation_to_contact', 'lead_knee_extension_to_contact', + 'torso_inclination_at_contact', 'shoulder_rotation_after_contact'] + group: Literal['balance_load', 'power_move', 'contact_follow_through'] + unit: Literal['deg'] = 'deg' + reference: Literal['torso_angle_from_vertical', 'signed_horizontal_shoulder_minus_hip_heading', + 'absolute_net_horizontal_rotation', 'change_in_3d_lead_knee_angle'] + event_id: Literal['stride_start', 'contact'] | None = None + start_event_id: Literal['front_foot_down', 'contact'] | None = None + end_event_id: Literal['contact', 'follow_through'] | None = None + + def model_dump(self, **kwargs): + data = super().model_dump(**kwargs) + return {k: v for k, v in data.items() if k not in ('event_id', 'start_event_id', 'end_event_id') or v is not None} + + class MotionCoachPayload(Strict): - schema_version: Literal['1.0'] = '1.0' - measurement_definitions_version: Literal['1.0'] = '1.0' + schema_version: Literal['1.0', '1.1'] = '1.1' + measurement_definitions_version: Literal['1.0', '1.1'] = '1.1' analysis_id: str = Field(min_length=1) analysis_revision: int = Field(ge=1) swing_id: str = Field(min_length=1) @@ -107,10 +144,23 @@ class MotionCoachPayload(Strict): athlete: CoachAthlete context: CoachContext events: CoachEvents - measurements: list[SeparationAtFootDown | RelativeStride | SeparationAtContact] = Field(min_length=3, max_length=3) + measurements: list[SeparationAtFootDown | RelativeStride | SeparationAtContact | ExtendedMeasurement] = Field(min_length=3, max_length=9) @model_validator(mode='after') def metric_set(self): - if len({m.metric_id for m in self.measurements}) != 3: + expected = {'hip_shoulder_separation_at_foot_down', 'stride_relative_length', 'hip_shoulder_separation_at_contact'} + if self.schema_version == '1.1': + expected.update(EXTENDED_METRICS) + if self.measurement_definitions_version != self.schema_version: + raise ValueError('Schema and measurement definitions versions must match') + if {m.metric_id for m in self.measurements} != expected or len(self.measurements) != len(expected): raise ValueError('Each registered metric must appear exactly once') return self + + def model_dump(self, **kwargs): + data = super().model_dump(**kwargs) + for row in data['measurements']: + for key in ('event_id', 'start_event_id', 'end_event_id'): + if row.get(key, 'absent') is None: + row.pop(key) + return data diff --git a/baseball_batting/motion_evidence.py b/baseball_batting/motion_evidence.py index 0881408d6667f5a74af6e6be697d9aa9076fed77..9d93c882f45c6d907b8e781f34d2d69a3936f57e 100644 --- a/baseball_batting/motion_evidence.py +++ b/baseball_batting/motion_evidence.py @@ -76,13 +76,21 @@ def collect(job,video,capture,models,options,progress,device='cuda'): reverse_flow=np.zeros((n,j),bool);reverse_testable=np.zeros((n,j),bool) previous=None;prior=None;prior_scores=None;prior_time=None;old_box=None camera_displacement=np.full(n,np.nan) + anchor_displacement=np.full(n,np.nan) + anchor_gray=None;anchor_box=None;anchor_time=None times=np.array([r['physical_s'] if r['physical_s'] is not None else r['playback_s'] for r in capture['frames']]) sequence=np.zeros(n,int);serial=0 for i,_,_,image in iter_frames(video,capture['rotation_degrees']): if i>=n:raise ValueError('Evidence source changed after ingest') box=boxes[i];gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) if box is None or tracker['reasons'][i] is not None: - previous=None;prior=None;prior_scores=None;prior_time=None;old_box=None;serial+=1;sequence[i]=serial;continue + previous=None;prior=None;prior_scores=None;prior_time=None;old_box=None + anchor_gray=None;anchor_box=None;anchor_time=None + serial+=1;sequence[i]=serial;continue + if anchor_gray is None: + anchor_gray=gray.copy();anchor_box=box;anchor_time=times[i] + elif i%8==0 and times[i]-anchor_time>=.25: + anchor_displacement[i]=background_motion(anchor_gray,gray,anchor_box,box) points,score=pose(image,box);heights[i]=max(box[3]-box[1],1) for k,name in enumerate(NAMES): index=OBSERVATIONS[name];pixels[i,k]=points[index];scores[i,k]=score[index] @@ -105,7 +113,8 @@ def collect(job,video,capture,models,options,progress,device='cuda'): evidence={'pixels':pixels,'weights':weights,'scores':scores,'box_heights':heights, 'frame_usable':usable,'flow_supported':flow,'flow_testable':flow_testable,'sequence_ids':sequence, 'reverse_flow_supported':reverse_flow,'reverse_flow_testable':reverse_testable, - 'background_displacement_image_fraction':camera_displacement} + 'background_displacement_image_fraction':camera_displacement, + 'background_anchor_displacement_image_fraction':anchor_displacement} if options.camera and options.camera.distortion is not None:evidence['distortion']=np.array(options.camera.distortion) np.savez_compressed(job/'motion-evidence-private.npz',**evidence) metadata={'version':'rtmw-image-evidence-v2','model_sha256':sha256_file(paths['body_pose']), @@ -117,6 +126,8 @@ def collect(job,video,capture,models,options,progress,device='cuda'): 'camera_motion':'background affine RANSAC displacement; diagnostic only, not ground/world calibration', 'camera_motion_evaluable_pairs':int(np.isfinite(camera_displacement).sum()), 'maximum_background_displacement_image_fraction':float(np.nanmax(camera_displacement)) if np.isfinite(camera_displacement).any() else None, + 'camera_anchor_evaluable_pairs':int(np.isfinite(anchor_displacement).sum()), + 'maximum_background_anchor_displacement_image_fraction':float(np.nanmax(anchor_displacement)) if np.isfinite(anchor_displacement).any() else None, 'implementation_sha256':sha256_file(__import__('pathlib').Path(__file__))} atomic_json(job/'motion-evidence-private.json',metadata) return evidence,metadata diff --git a/baseball_batting/motion_refine.py b/baseball_batting/motion_refine.py index a8f9b531e739512625d649e5118e0c7a9260aced..c5d74eb2f1653db86138d79547d682fa95b9ffe1 100644 --- a/baseball_batting/motion_refine.py +++ b/baseball_batting/motion_refine.py @@ -12,6 +12,17 @@ def implementation_hash(): ('motion_refine.py','motion_refine_worker.py','motion_refinement.py','motion_evidence.py','temporal3d.py','geometry.py')}) +def static_camera_conflict(arrays, threshold): + """Check persistent drift against an anchor as well as consecutive images. + +Never sum unsigned motion: stationary-camera tracking noise would accumulate too. +""" + adjacent=np.asarray(arrays['background_displacement_image_fraction']) + anchor=np.asarray(arrays.get('background_anchor_displacement_image_fraction', [])) + return bool(np.count_nonzero(np.isfinite(adjacent)&(adjacent>threshold))>=3 or + np.count_nonzero(np.isfinite(anchor)&(anchor>max(.01,threshold*3)))>=3) + + def refine(job,video,capture,raw,models,options,progress): job=Path(job) metadata={'version':VERSION,'enabled':options.refinement.enabled,'accepted_frame_count':0, @@ -24,11 +35,10 @@ def refine(job,video,capture,raw,models,options,progress): metadata['reason_code']='native_parameters_unavailable';return raw,metadata from .motion_evidence import collect arrays,evidence=collect(job,video,capture,models,options,progress) - displacement=arrays['background_displacement_image_fraction'] - moving=np.isfinite(displacement)&(displacement>options.refinement.maximum_static_background_motion_fraction) # A caller's static declaration is contradicted only by multiple robust # background observations. This never establishes a calibrated world frame. - conflict=bool(options.camera_stability=='fixed_verified' and np.count_nonzero(moving)>=3) + conflict=bool(options.camera_stability=='fixed_verified' and static_camera_conflict( + arrays,options.refinement.maximum_static_background_motion_fraction)) evidence['declared_static_camera_conflict']=conflict if evidence['frames_with_minimum_support']<4: metadata.update(reason_code='insufficient_image_evidence',image_evidence=evidence);return raw,metadata diff --git a/data_ref/calibration/contract_v1_1/contract_v1_1_benchmarks.json b/data_ref/calibration/contract_v1_1/contract_v1_1_benchmarks.json new file mode 100644 index 0000000000000000000000000000000000000000..a7d0daf1c06c6e2d5a75dec31ae37a3f982f2583 --- /dev/null +++ b/data_ref/calibration/contract_v1_1/contract_v1_1_benchmarks.json @@ -0,0 +1,289 @@ +{ + "source": "OpenBiomechanics dataset-v1; hitting_landmarks.zip", + "source_url": "https://github.com/drivelineresearch/openbiomechanics/releases/tag/dataset-v1", + "landmarks_sha256": "93e4b3d8efbc6701fcf6610876e8ce2186311af0fc2dd0b467a3b66af0cc6e23", + "metadata_sha256": "b87567a7dbed13dd438a16512b80b80af81cf909e1203a89f545e6b31a245372", + "n_swings": 649, + "n_athletes": 97, + "definition_version": "1.1", + "follow_through_seconds": 0.1, + "limitations": "Laboratory reference intervals, not ideal technique or validated phone-video accuracy.", + "metrics": { + "torso_inclination_at_stride_start": { + "right/high_school": { + "n_athletes": 12, + "n_swings": 54, + "p10": 13.647, + "p25": 16.477, + "p50": 18.132, + "p75": 22.165, + "p90": 26.95 + }, + "right/college": { + "n_athletes": 50, + "n_swings": 312, + "p10": 10.482, + "p25": 12.451, + "p50": 17.587, + "p75": 21.514, + "p90": 23.561 + }, + "right/pro": { + "n_athletes": 8, + "n_swings": 46, + "p10": 10.569, + "p25": 12.79, + "p50": 16.559, + "p75": 19.706, + "p90": 20.202 + }, + "left/high_school": { + "n_athletes": 0, + "n_swings": 0 + }, + "left/college": { + "n_athletes": 23, + "n_swings": 148, + "p10": 7.027, + "p25": 10.876, + "p50": 15.483, + "p75": 20.913, + "p90": 21.64 + }, + "left/pro": { + "n_athletes": 4, + "n_swings": 21 + } + }, + "hip_shoulder_separation_at_stride_start": { + "right/high_school": { + "n_athletes": 12, + "n_swings": 54, + "p10": -19.805, + "p25": -15.439, + "p50": -8.689, + "p75": -5.326, + "p90": -2.582 + }, + "right/college": { + "n_athletes": 50, + "n_swings": 312, + "p10": -15.908, + "p25": -13.629, + "p50": -8.338, + "p75": -6.051, + "p90": 0.649 + }, + "right/pro": { + "n_athletes": 8, + "n_swings": 46, + "p10": -10.813, + "p25": -7.626, + "p50": -5.479, + "p75": -3.168, + "p90": 0.28 + }, + "left/high_school": { + "n_athletes": 0, + "n_swings": 0 + }, + "left/college": { + "n_athletes": 23, + "n_swings": 148, + "p10": -4.207, + "p25": -1.404, + "p50": 3.77, + "p75": 7.816, + "p90": 9.349 + }, + "left/pro": { + "n_athletes": 4, + "n_swings": 21 + } + }, + "pelvis_rotation_to_contact": { + "right/high_school": { + "n_athletes": 12, + "n_swings": 75, + "p10": 71.621, + "p25": 95.252, + "p50": 101.385, + "p75": 109.403, + "p90": 113.136 + }, + "right/college": { + "n_athletes": 50, + "n_swings": 339, + "p10": 87.519, + "p25": 92.239, + "p50": 99.919, + "p75": 112.851, + "p90": 119.838 + }, + "right/pro": { + "n_athletes": 8, + "n_swings": 54, + "p10": 91.703, + "p25": 101.744, + "p50": 107.33, + "p75": 110.155, + "p90": 111.75 + }, + "left/high_school": { + "n_athletes": 0, + "n_swings": 0 + }, + "left/college": { + "n_athletes": 23, + "n_swings": 158, + "p10": 71.154, + "p25": 91.944, + "p50": 102.235, + "p75": 109.794, + "p90": 116.492 + }, + "left/pro": { + "n_athletes": 4, + "n_swings": 23 + } + }, + "lead_knee_extension_to_contact": { + "right/high_school": { + "n_athletes": 12, + "n_swings": 75, + "p10": 13.012, + "p25": 20.026, + "p50": 26.679, + "p75": 33.401, + "p90": 46.79 + }, + "right/college": { + "n_athletes": 50, + "n_swings": 339, + "p10": 11.016, + "p25": 24.36, + "p50": 30.214, + "p75": 37.117, + "p90": 41.516 + }, + "right/pro": { + "n_athletes": 8, + "n_swings": 54, + "p10": 25.249, + "p25": 26.439, + "p50": 31.089, + "p75": 39.377, + "p90": 44.219 + }, + "left/high_school": { + "n_athletes": 0, + "n_swings": 0 + }, + "left/college": { + "n_athletes": 23, + "n_swings": 158, + "p10": 18.307, + "p25": 22.863, + "p50": 27.741, + "p75": 35.16, + "p90": 44.186 + }, + "left/pro": { + "n_athletes": 4, + "n_swings": 23 + } + }, + "torso_inclination_at_contact": { + "right/high_school": { + "n_athletes": 12, + "n_swings": 75, + "p10": 23.44, + "p25": 23.757, + "p50": 25.992, + "p75": 28.781, + "p90": 31.166 + }, + "right/college": { + "n_athletes": 50, + "n_swings": 339, + "p10": 19.666, + "p25": 23.095, + "p50": 25.627, + "p75": 29.757, + "p90": 34.174 + }, + "right/pro": { + "n_athletes": 8, + "n_swings": 54, + "p10": 23.969, + "p25": 25.461, + "p50": 27.233, + "p75": 29.828, + "p90": 32.311 + }, + "left/high_school": { + "n_athletes": 0, + "n_swings": 0 + }, + "left/college": { + "n_athletes": 23, + "n_swings": 158, + "p10": 23.096, + "p25": 26.972, + "p50": 28.916, + "p75": 30.407, + "p90": 32.363 + }, + "left/pro": { + "n_athletes": 4, + "n_swings": 23 + } + }, + "shoulder_rotation_after_contact": { + "right/high_school": { + "n_athletes": 12, + "n_swings": 75, + "p10": 30.717, + "p25": 33.222, + "p50": 46.241, + "p75": 49.491, + "p90": 50.917 + }, + "right/college": { + "n_athletes": 50, + "n_swings": 339, + "p10": 24.678, + "p25": 32.14, + "p50": 39.678, + "p75": 42.911, + "p90": 50.737 + }, + "right/pro": { + "n_athletes": 8, + "n_swings": 54, + "p10": 39.631, + "p25": 41.326, + "p50": 48.357, + "p75": 51.044, + "p90": 57.817 + }, + "left/high_school": { + "n_athletes": 0, + "n_swings": 0 + }, + "left/college": { + "n_athletes": 23, + "n_swings": 158, + "p10": 28.626, + "p25": 34.359, + "p50": 40.799, + "p75": 44.89, + "p90": 53.315 + }, + "left/pro": { + "n_athletes": 4, + "n_swings": 23 + } + } + } +} diff --git a/data_ref/calibration/contract_v1_1/contract_v1_1_swings.csv b/data_ref/calibration/contract_v1_1/contract_v1_1_swings.csv new file mode 100644 index 0000000000000000000000000000000000000000..92bd6f5a241da6dc9199a1716b179658530fe20b --- /dev/null +++ b/data_ref/calibration/contract_v1_1/contract_v1_1_swings.csv @@ -0,0 +1,650 @@ +session_swing,user,level,batting_hand,torso_inclination_at_stride_start,hip_shoulder_separation_at_stride_start,pelvis_rotation_to_contact,lead_knee_extension_to_contact,torso_inclination_at_contact,shoulder_rotation_after_contact +103_1,4,high_school,right,,,104.09567217634621,2.618497466742639,20.360388123034582,38.22825015049175 +103_2,4,high_school,right,23.65939510329163,-9.227589592741708,107.2561214617355,10.068870610854333,20.87740988153495,42.83559054040865 +103_3,4,high_school,right,24.27615199918751,-11.820911220702925,114.69978928990753,9.267077217888414,18.67074368613606,36.62524814323058 +103_4,4,high_school,right,,,109.17503915600497,3.73622008898235,15.740625200535211,40.81593077026347 +103_5,4,high_school,right,21.342347423098758,-11.460783805902679,108.36244960132767,18.85564852952527,18.561280918297584,42.97384288901913 +111_1,10,college,left,15.470214932812919,8.789841377725281,104.44707825364596,17.801178369246458,32.32964947780761,39.218719111474286 +111_2,10,college,left,15.803915443693109,6.78889914807462,109.57808223097676,16.874713526520168,30.65711519543637,47.03116319109468 +111_3,10,college,left,14.916718590650431,10.429064888029814,116.62950635834692,16.534957977691477,29.810809064632135,46.744289148772204 +111_4,10,college,left,16.280029440902215,7.840764312745478,112.82835405185975,18.299749904617357,31.438540389036557,38.47471559485175 +111_5,10,college,left,14.887754060918295,8.786872280478406,115.23992843153795,15.271254694416115,26.242306046386435,34.40995531982166 +111_6,10,college,left,15.495061677185529,8.162608593984203,109.09691807712164,21.707557368058247,32.64001388116701,51.702473217379804 +111_7,10,college,left,16.158339154555087,9.570394240653997,113.68603323479694,17.9203459223435,30.173819573957815,39.08306766455865 +111_8,10,college,left,14.876284012896582,10.145001923102285,102.7254427768659,21.683851780266025,35.087386784614644,52.8282952962862 +121_1,22,college,right,10.998831398518366,-7.946029751534894,88.04910777446248,29.050558872460726,24.538305736123334,27.896671243454303 +121_2,22,college,right,13.20928399801353,-8.271068463529758,84.32171917036055,36.760945664456585,23.009235046077897,18.623161076124617 +121_3,22,college,right,13.344867305769272,-8.812349359229728,75.8203914949066,39.093710734688216,28.16870837154781,30.69330520538268 +121_4,22,college,right,14.379587899696837,-1.2310218443115843,80.25257213341276,31.993773815685387,22.817242574521945,32.85153422167357 +121_5,22,college,right,13.23878731698202,-6.397098348882395,79.9240171880213,31.90881703290401,32.64453914089073,61.1925100265869 +121_6,22,college,right,11.999659939443944,-7.955569056283991,86.00710214991278,30.276379308758578,27.09909722909223,50.88331131933354 +121_7,22,college,right,12.79105469680178,-6.197815049816171,88.57322023182674,29.611616110462393,22.00548297624345,36.36465462028883 +121_8,22,college,right,11.781040547477726,-5.882406416029795,76.414863064153,32.106267470334615,30.69211097318358,57.85287854788372 +123_1,9,college,right,26.310379008743332,-11.966191131790907,113.34404096719476,34.585671696743745,21.679461969590943,23.679103462702834 +123_2,9,college,right,26.248016341869494,-13.291760792492369,116.5094862898675,33.211326972253204,24.00592238319215,25.986187789504534 +123_3,9,college,right,26.19964880825191,-11.76673083326898,115.40542032635913,31.331143033917755,19.713604514229086,16.06406419278643 +123_4,9,college,right,,,116.57762054569993,40.218374304647114,22.046039982636316,19.10042049132321 +123_5,9,college,right,27.495413420094675,-11.85088048506779,113.00097500105285,23.62062369303797,21.465425790727224,21.730110523165113 +123_6,9,college,right,26.83524458200702,-10.03251975468092,112.01881133704802,28.00441313087326,22.176484785942044,16.42412656835637 +123_7,9,college,right,25.59254191783836,-11.253066592803094,99.78803192516057,21.309763191271287,23.257613969677305,18.93308851174657 +123_8,9,college,right,27.16015681852024,-13.887175941128334,99.7525616230455,22.424223663939728,31.486880622206314,27.06823002315442 +123_9,9,college,right,25.073295709960146,-12.584051432263493,96.87337214792956,20.696225764161014,23.674204084964437,26.309838237346707 +125_1,24,college,left,20.63378846006004,14.167536359858047,93.46401512216731,31.531382093534205,26.243724089219896,20.497980229478152 +125_2,24,college,left,19.947973062038802,13.518522978946521,91.86440619226876,26.54360829933526,21.637335691538222,21.04910489997312 +125_3,24,college,left,20.852907506666412,12.171677722389063,90.60148047731865,28.05597456795809,21.46536030096211,21.435561388357986 +125_4,24,college,left,22.024608917400297,9.959830469930182,101.13971493704828,24.738473200513198,22.891437081507675,18.019434526920623 +125_5,24,college,left,,,94.87899291942107,30.213296460539198,23.333802977430896,25.740319447972848 +125_6,24,college,left,22.417829361517665,7.754915278855975,98.37506217941257,28.486275722445328,25.25521738684364,28.968728273463697 +125_7,24,college,left,22.061340319872834,10.120432033864887,97.11723122409776,20.174744625378338,20.741778653554245,31.433541425576497 +140_1,37,college,right,8.132743022090754,-5.791158482366086,103.98892122546322,29.203893287592678,26.041807789090466,29.583249904290685 +140_2,37,college,right,8.707986250785153,-6.171712613620798,100.4096355043368,31.757074188760896,27.345095770451834,24.569997899734734 +140_3,37,college,right,6.93221376110782,-6.79008368629718,102.11948361655102,23.757729677413806,24.917268843705916,36.58949020266819 +140_4,37,college,right,8.713884592399685,-7.244517113942948,105.34202500697882,25.533328692808254,24.627364545729836,20.759924102863863 +140_5,37,college,right,7.761471539937497,-4.690030175939,107.4860847482179,21.132437681798734,21.89703032030471,9.625563581145887 +140_6,37,college,right,6.903812960752211,-8.060866214961493,105.30489818938841,20.36545413264031,23.009838863388477,11.545491729684104 +140_7,37,college,right,9.70834682497276,-6.312742931465095,106.76647167888173,35.08448626626421,27.244167360790556,19.852282140501494 +140_8,37,college,right,6.384586953051916,-8.766138359605748,102.01310788128492,28.901491016543133,26.88543054875039,33.03529369117051 +160_1,51,college,right,18.244833052662898,-14.211407285013507,94.54696633104881,14.197404530159957,38.13178540023648,36.26817187898416 +160_2,51,college,right,17.381607740380417,-16.705315068294738,92.37011546353585,9.045715148769375,36.2894878000453,26.45050455779171 +160_3,51,college,right,19.43487188209779,-15.115004264546116,89.98327044327648,6.061526943255188,40.21078749872489,44.543422444889 +160_4,51,college,right,18.521139250476207,-16.222790273843202,84.16609959101213,21.495536982307357,39.87357769168835,60.55743588133075 +160_5,51,college,right,16.48937285533872,-14.989361404932794,94.58146456585686,10.221537249388575,36.89084846347824,29.585291922559158 +160_6,51,college,right,26.1444884048266,-6.923383210008751,89.62108925896666,20.65822298602879,43.43839891986632,49.41529815732865 +160_7,51,college,right,14.840311617775342,-15.63371523374741,100.00950383945724,11.995972641123103,36.69875283948351,24.824348756375063 +160_8,51,college,right,16.334168697142854,-13.840839261682987,111.05055488870457,2.73069350938286,35.481538393207835,23.956823841049786 +164_1,54,pro,left,3.407315691759055,-0.5077449737259769,93.49521588022075,37.22191873546646,32.13114796943525,35.475819760868745 +164_2,54,pro,left,,,97.26547072409451,39.737674610266595,29.563254395770272,34.07110356641189 +164_3,54,pro,left,2.472369863715987,1.898870662101217,97.47639887436772,36.06182869827887,31.560769941812243,37.86594966352173 +164_4,54,pro,left,3.899049422380016,-1.000833906410321,96.15128485887776,35.41569522803596,31.370448760215115,42.448343226256355 +164_5,54,pro,left,3.807801636175686,1.0125978664556214,100.21140137638258,35.62835107397993,29.15566401345345,42.39913953006988 +164_6,54,pro,left,3.488316843868418,0.8419286466166227,99.53338771335484,39.49614415576369,30.294530517612525,40.45777357636886 +164_7,54,pro,left,3.884234392599735,1.1853862693433825,94.91192205097522,37.7897551054715,28.821471224473825,36.1972887023781 +164_8,54,pro,left,2.6822890241049735,0.9786713294404024,101.46012652517123,35.970383406452356,29.56055374248351,37.253779096175194 +164_9,54,pro,left,,,97.45606401938561,35.79565841653212,29.35673883890893,38.88506962668005 +167_1,56,college,right,,,96.08449046118155,41.10899950551001,36.416083332779685,53.97589718865744 +167_2,56,college,right,15.251023580387464,-12.474838993906303,96.99719139296911,42.8556547295766,35.28485147127111,60.901168799078576 +167_3,56,college,right,13.8239213938177,-13.875294324815968,93.9846074560846,38.76896387212071,33.7800258993099,53.19009580665626 +167_4,56,college,right,15.018849625277818,-13.286951798204313,98.85742302145734,40.00749826400971,35.33146170231119,59.649779160104245 +167_5,56,college,right,13.889012674438776,-12.618058948621837,96.35302034132172,40.20138105989085,34.12921254158694,61.843219097870225 +167_6,56,college,right,15.090493896834845,-10.962814273947629,93.15533894828306,42.347536527705614,36.665439643877825,62.44983068795219 +167_7,56,college,right,14.204948641485228,-11.99312004917195,94.74861440990021,39.74810861079138,34.22624598870272,58.93917747114097 +167_8,56,college,right,14.176089161760892,-12.818553183634435,95.64022651403464,40.66368083455541,35.296170108149035,59.02948509288356 +17_1,59,pro,right,16.75025541867476,-0.35551330441231244,98.2207684759511,45.587685955843966,30.500550797831313,41.77873894389693 +17_2,59,pro,right,17.670971874444636,-1.015442983848402,108.23439420329966,53.222942429580286,31.756123419615825,41.25909913835249 +17_3,59,pro,right,20.001466784688073,4.268043397270446,104.55982531419535,44.04962082975695,25.077394651552535,45.112854588853736 +17_4,59,pro,right,19.556613550536294,3.2900884673634607,105.84017104916903,53.92949097288367,25.64999438726603,43.03365137693636 +17_5,59,pro,right,22.42255456152757,2.5486115759852908,104.80748622727758,52.373381524624804,23.090694011506255,41.39821988423507 +174_1,19,high_school,right,12.920901542749215,-5.49766145729194,130.67775491643505,52.6692423204518,27.16891789760982,46.5048329628806 +174_3,19,high_school,right,14.61040811056955,-6.758783900238171,124.64856529982006,52.946433880870615,26.670811424639687,42.99167640239165 +174_4,19,high_school,right,,,123.01227523138543,49.22995189309671,22.430660711399504,50.55119936956151 +174_5,19,high_school,right,,,99.73401237753417,47.92695801524779,26.06723981838993,48.345715056120234 +174_7,19,high_school,right,13.347731367194504,-4.772049037031479,114.77984428947488,52.33764683708205,23.187701809910575,51.15281236484324 +174_8,19,high_school,right,,,118.23655264506657,49.28992308534173,25.06501600304573,45.949467426152644 +178_1,64,college,right,13.91298299467024,-6.046474057968794,82.72959863014071,21.865138099795303,38.534327240768846,51.55673749895187 +178_2,64,college,right,14.745603187268522,-5.982402720127112,85.91829820300168,12.583590853346067,40.51068308773668,47.36797739265007 +178_3,64,college,right,14.194347923236167,-6.269097726688642,88.581117366914,20.150564826862762,41.57999242203263,50.080580516677344 +178_4,64,college,right,11.219370025925269,-8.080641953704685,83.37886605487698,22.41129441472563,40.91858671136209,56.57342084083786 +178_5,64,college,right,10.141367881034753,-5.1691689962734415,100.7962622844682,27.75484255090103,37.95031774182584,51.271446586934445 +178_6,64,college,right,12.879249921581982,-6.909963726106753,87.47836964500236,17.47689678194226,39.90103955008897,55.43591622670282 +178_7,64,college,right,9.265962772617545,-7.93467061400753,92.2723910932421,11.363939548525224,39.583600820834725,49.439155072245114 +178_8,64,college,right,13.910968802822017,-8.778589885488032,88.70354320781846,18.935970916546637,40.11007073854209,46.48231603922458 +179_1,65,college,right,12.851036488873817,-24.48568687898964,115.99663407700248,42.69525747697014,27.323960316368712,35.058115301098276 +179_2,65,college,right,12.380888905065461,-24.9395680547282,111.5155214484396,39.37373822297522,27.91319643490451,39.04801417348382 +179_3,65,college,right,12.356528818149847,-24.570768240839755,125.15748887331192,37.83644271794458,30.762091602230814,39.075674497310686 +179_4,65,college,right,,,118.48389597650859,38.91531604301559,30.03613529063151,36.53412912960939 +179_5,65,college,right,12.286056324558626,-24.388828482631368,120.41003045770205,43.01645080277302,27.015575902324976,39.995308996780885 +179_6,65,college,right,12.733890585552501,-25.684329694781383,123.58262495476963,41.2689280002198,27.19045114071157,22.90627223719198 +179_7,65,college,right,,,121.62904505571142,41.23746482583667,31.10078472404912,49.31840673685844 +180_1,67,college,right,24.143970282791372,2.3351193600580302,89.4600542960091,5.395707494523009,22.706680702168725,54.658354004101135 +180_2,67,college,right,24.062372658717003,4.665722216477803,93.2104468095282,13.623282868100432,20.909180197908373,55.29728675814765 +180_3,67,college,right,22.70745855018677,-2.9775730704054126,87.99627499237982,9.71793813619135,23.755432815694448,45.65695909917638 +180_4,67,college,right,20.956828434849605,0.6731986480027103,91.806635835099,12.425647513421382,21.228572070412152,47.77232744703567 +180_5,67,college,right,22.583197147338016,-0.4526520813966499,88.96849485980755,9.57075573093195,24.634510670644136,48.99536622760482 +180_6,67,college,right,21.140881077689098,-0.6922892079532517,89.03128015840971,10.180299385831233,24.341813298496376,50.45304051794855 +180_7,67,college,right,21.190261678432638,-0.3066819195540802,100.37145005022502,17.927327269685236,23.715725893336373,43.735523603427005 +181_1,68,college,right,15.147429647664124,-19.51032495110053,119.16893887608425,39.82863975853954,25.131392088988402,46.29586632167905 +181_2,68,college,right,,,121.24778301664992,47.7744506889409,28.834242308860205,38.0495375615753 +181_3,68,college,right,,,119.67417446861525,51.19460039812955,26.912641070737774,36.56221399445134 +181_4,68,college,right,16.315371576474018,-20.144670319889002,119.87521642406723,47.2417843668446,26.054970967045353,44.82571134201734 +181_5,68,college,right,15.435329326458618,-20.196460396552055,124.58915504724669,41.500735421697485,25.49470125508413,45.27993973474149 +181_6,68,college,right,13.945843417554753,-19.961995396448003,115.42015875517666,24.37192130748366,22.16358687015164,32.942104242989885 +181_7,68,college,right,16.198549609426028,-20.757360172492014,123.90805714601626,50.32920841140046,26.367961409465103,33.03316064235501 +181_8,68,college,right,15.102280947519453,-20.65679209104755,115.43740307662624,44.7171278424956,21.829405820324066,37.62897808002054 +185_1,71,high_school,right,,,101.60848920159337,28.887222448538097,24.490196704728298,46.982744607633094 +185_2,71,high_school,right,14.738567800958053,-12.792250541695608,107.21062512849541,26.849182438729912,22.909437284674443,54.66093146258608 +185_3,71,high_school,right,16.640318045334006,-15.762801158277227,107.13674917307321,30.532689049977023,21.620118871895652,46.838039157935434 +185_4,71,high_school,right,16.582584178572212,-13.731136640445698,113.64898625751282,36.09427324405331,25.498142780757227,47.842608220068016 +185_5,71,high_school,right,16.10201772968748,-14.508839915210245,106.89800686833419,32.84442861220117,24.504879611364228,47.280529109930065 +185_6,71,high_school,right,,,109.27595152686767,29.33349453137555,24.927058146639485,44.72548262909273 +190_1,76,college,right,11.3732183470866,-8.693224497574874,102.08882315914863,19.68573265903987,29.77973242694225,37.368109167116096 +190_2,76,college,right,13.91598654913794,-11.42886372265059,104.38508924486517,24.76308750516847,23.688724676122607,36.634440107872905 +190_3,76,college,right,15.068941800643621,-10.89731864223711,112.17850975201677,30.21549669201292,26.86445067471899,29.67301269526437 +190_4,76,college,right,13.940070446216208,-6.688710426615415,100.26890459915944,36.33912556947172,26.932221632562698,30.57273097058308 +190_5,76,college,right,15.494676962003432,-9.262114932885225,102.48391141411675,31.764301722662765,28.07531659933953,37.02017679130561 +190_6,76,college,right,18.04375591972349,-4.551420942135252,106.46028415568364,25.540300596663428,22.1377960709916,37.50675351091052 +190_7,76,college,right,13.639704448455202,-13.63065432904483,87.30760181345103,31.01834441316953,23.6006181597092,36.87117048367007 +190_8,76,college,right,15.673150764976546,-11.411145855697015,91.50546067535198,34.63072605026605,19.27981487363006,32.92031276502583 +198_7,82,college,right,10.96776258194756,-15.662868290869653,131.84921764016067,33.2386146672107,34.050037642562835,42.352086288524944 +199_1,83,college,right,,,92.22172636224245,32.74839156467539,36.20644878949132,35.44192144046546 +199_2,83,college,right,6.886742022065478,-15.320234134398333,93.10785747282877,34.28972796050073,34.95045752800055,42.23007349547876 +199_3,83,college,right,,,96.0052040383628,39.75046990531857,37.34293183745516,33.40110221744184 +199_4,83,college,right,,,89.30412799227105,32.942504500182764,35.999467147441656,48.93864833209792 +199_5,83,college,right,7.447526314250605,-15.999605236345587,88.76646200567964,33.718605674329325,34.46419698309318,45.58584254523383 +199_6,83,college,right,7.946411807948689,-15.894697356590086,94.25394097824254,34.04607581636108,36.42169466684509,44.09541431142689 +199_7,83,college,right,6.659950286886434,-15.278063417724638,91.44376784100122,33.83967419505808,36.31848313414903,44.69201888243217 +199_8,83,college,right,7.9848903709826144,-16.453705788433467,90.18861813990522,35.12091160525512,36.375286256121726,43.14822217734407 +200_1,85,college,left,21.86012381339158,3.752271323487861,106.40332312977075,25.399308140448767,31.573383910924374,44.30668028933704 +200_2,85,college,left,21.087952553991997,2.4607142127411805,115.31267874180108,23.431208597933505,30.729049770317108,47.187180081306096 +200_3,85,college,left,,,121.88065803390981,23.939862867187315,32.893360641830455,49.88069168609927 +200_4,85,college,left,,,120.48542633096393,27.265264576590738,30.2992070038202,42.62288756072907 +200_5,85,college,left,21.38758699635571,0.3157531021680313,115.53672637850578,20.462704512961466,29.54191701759045,44.936558864195774 +200_6,85,college,left,20.05874050659158,3.4031351059115025,115.6617336592411,20.49018246091842,31.8868015586244,39.869795443401806 +200_7,85,college,left,20.739573331065856,3.333491917183835,120.36912917481925,28.93672287879275,30.12230484443322,41.822189177534455 +200_8,85,college,left,19.6714999862379,3.1234167928470526,118.62499844515847,27.82224466884415,28.123523121313937,45.92893872341942 +201_1,86,college,right,8.648046351791132,-14.476284556903465,83.18249714317972,0.4239897257937173,15.662299657466951,35.46311182415625 +201_2,86,college,right,8.963823671550935,-12.94389195186352,85.78526886510843,0.42674692160952077,16.497171172968276,30.23589109259625 +201_3,86,college,right,9.899372044729821,-14.567381126677333,91.80398431086401,3.787127347400002,15.405378670265426,22.226800432569913 +201_5,86,college,right,7.394171446530793,-15.110759916980669,89.96232000613543,1.1256320146528935,18.440598624459447,30.745367176755742 +201_6,86,college,right,7.928279802972218,-13.260752747192328,89.72690063448826,3.0255087337016846,17.60604750486889,27.477558659191335 +201_7,86,college,right,9.037665763933171,-13.285832025196896,97.77692955950337,-5.167362455559527,16.390236488751807,35.329972902666675 +201_8,86,college,right,8.892852093483972,-14.97544744358106,88.38671332854982,1.1720704022189636,12.713012872638442,32.557176706129205 +203_1,87,college,left,10.988700957094233,9.268564583824144,118.77648496936303,27.421117161132514,21.378116927163383,24.339282291373348 +203_2,87,college,left,12.761889232970333,9.70962109598716,114.81637843113191,22.90607237475635,20.21582271559225,37.201876831301234 +203_3,87,college,left,,,112.95220489358069,19.206118576521988,20.616899678096946,37.04136848798533 +203_4,87,college,left,,,104.00105667065816,15.745144844886767,16.611557444603825,25.56343893663101 +204_1,88,college,right,22.96559647703061,-7.892921845614808,88.7624736110631,44.693824381599654,29.816647549307806,39.59549260071348 +204_2,88,college,right,21.05294827696044,-8.064892023592279,93.50925258529762,44.92610067858706,27.23915616133068,39.248001626121614 +204_3,88,college,right,21.340294574708782,-7.903391489655888,96.73884173267149,43.300044133681666,28.167143768190964,39.99916864774601 +204_4,88,college,right,,,90.95126344516729,43.85963979164072,29.85556432969508,57.39447225095351 +204_5,88,college,right,22.539284396196,-7.91697451926396,90.44264834710513,44.192637023852825,28.59342596757721,47.289114682292094 +204_6,88,college,right,22.003218003919002,-7.461281721802862,91.14477341353226,42.98454970752289,27.35228253124186,37.74393073327693 +204_7,88,college,right,22.171522048413195,-7.523892312550174,88.55356517067757,42.72982411621487,29.117080029390216,41.05353511400225 +204_8,88,college,right,22.830422320222304,-7.879772088691993,92.08552587171783,45.83688898790834,28.601565551570573,37.967429603564256 +21_1,92,college,right,22.917028413135938,-11.434264218039203,94.3952637706367,37.873530647227966,30.347732920197096,48.573312783540715 +21_2,92,college,right,24.145426672957278,-11.965388335417458,94.88483472857988,33.35424223417776,31.181121699810532,54.15045485923569 +21_3,92,college,right,,,97.04664159205711,38.16742482319967,28.207779157698983,47.89281962383599 +21_4,92,college,right,,,98.08986957726788,43.4044775616364,28.926633163511216,39.81500396886216 +21_5,92,college,right,,,94.35048176417973,41.584917091366435,34.44793464857539,53.12675178181013 +215_1,96,college,left,14.20491519996717,-5.476486836019035,78.09722496669131,25.281628045153752,29.19568552424222,41.246843270294406 +215_2,96,college,left,14.786071144593222,-3.381197658815381,82.20391801499508,19.35868566940536,29.391456719226632,38.09036610995067 +215_4,96,college,left,14.405894897461968,-6.632526557430907,83.00826713736059,26.880568624674652,32.434584364696704,40.35082442631185 +215_5,96,college,left,15.274231197010863,-1.7640932430630585,84.76046567809567,25.100231475594768,29.202417252063665,49.13198916423149 +219_1,99,college,left,3.076618003192992,4.546221312010374,97.70325171941245,34.49965550686605,30.758320458030745,20.852631301544708 +219_2,99,college,left,3.8203495848018743,4.653122625800336,63.415373808365956,36.8098358729836,30.58311610590352,25.524951064466904 +219_3,99,college,left,3.9220072803169304,2.7155850075832006,96.36056280674573,26.542710487935665,33.83718206267269,28.99136116381731 +219_4,99,college,left,4.269285611724009,2.4007308169767043,100.02388913592459,23.85759344240327,34.626961049072406,24.14586489581135 +219_5,99,college,left,5.222308689344795,2.962188041657072,96.57171762981955,26.788856792782354,33.63880622293765,29.198357250447813 +219_6,99,college,left,4.658304544782791,-0.25550749395995354,90.7289075603389,24.567761415814516,31.745473579168426,32.239565112781825 +219_7,99,college,left,5.080310303752241,1.297691333462268,105.28705338224249,28.693677269746928,30.63183020776786,24.88664239281014 +219_8,99,college,left,2.9176974287105106,3.7785619093481273,90.98519162249728,32.83612137092214,33.984033938369194,26.190741818017397 +23_1,109,college,left,5.756115633644103,-2.67637103635505,107.21155600787681,21.42351514011054,18.445717642402133,21.088119800881852 +23_2,109,college,left,7.714725520128617,-3.627835810251554,117.80579802144435,7.553742731371443,32.016011858132615,28.382975260882503 +23_3,109,college,left,6.682312768910112,-3.721166463436873,107.45098613648655,16.028477197043998,29.11928670380705,28.630414885884967 +23_4,109,college,left,5.865276929427217,-2.0657025160191154,106.45756546385373,26.139712085105856,28.04075788265717,31.333350231459892 +23_5,109,college,left,7.175098211827835,-3.318629256730162,96.5782070195771,20.173414536036944,30.26179018115036,19.109240117205644 +236_1,113,pro,left,27.328494796369807,4.668404844430199,119.94323688619825,31.713400288038144,29.497578052404332,38.405694245566515 +236_2,113,pro,left,27.572635453154124,2.292877338554888,110.99761711446254,30.964765013807124,28.46076711103238,41.951299983551365 +236_3,113,pro,left,26.9626848120681,2.764525266468212,106.87404692478734,34.3638085862884,37.87593860460165,50.44257173607282 +236_4,113,pro,left,26.910910935030234,4.485371267458731,118.61894314959736,32.648999479198665,33.617281706054904,49.23656428338214 +24_1,116,college,right,19.085894335347337,-9.248354088358838,111.74221797226456,39.18057937463786,32.986808618977484,57.370122920364885 +24_2,116,college,right,19.09110638445545,-8.243318322703516,119.21412112879476,42.232696659331,34.420688833797406,57.76145996959995 +24_3,116,college,right,19.499887261156893,-6.469808107275355,127.58350235769302,46.10568844287198,32.07161599097036,49.28665688764217 +24_4,116,college,right,21.089999402742933,-7.020111122718362,118.43320453938058,31.964162494026766,31.554577456628262,57.51562049116048 +24_5,116,college,right,20.181912586002834,-5.429327467286242,119.5581221956328,36.057394341185244,30.232886334244775,58.71151996715961 +244_1,120,pro,right,,,120.52114222022873,27.836717038120156,22.652387030176577,38.9079409896137 +244_2,120,pro,right,20.029630149236176,-8.585743702431728,109.21256482530885,34.63765379794279,19.393532764190198,38.675240893637316 +244_3,120,pro,right,18.025959086917428,-7.752363647080273,120.86628510189396,24.88789690560884,20.958416611562903,40.32294207268455 +244_4,120,pro,right,18.505726710989183,-6.4896928005994425,112.04482029109566,26.17681127262776,14.324925799705778,39.61546227247838 +244_5,120,pro,right,18.221154135636855,-7.410588357274719,114.83238009726063,29.44691767729347,16.64819012939524,31.655609794328907 +244_6,120,pro,right,19.362065090074147,-8.74223283838296,110.5239925807167,33.81774137802276,23.000647829580533,45.12327027898357 +244_7,120,pro,right,19.459386591825197,-6.981470892660951,110.207666380347,28.149174475992567,22.929887432990558,42.72440459829362 +244_8,120,pro,right,,,114.8279601126395,22.02262800524761,25.132283221101385,49.397204261917416 +25_1,123,college,right,12.800705925500651,4.378417447713957,83.16210063112285,23.290351982836484,24.524106447458873,9.990027301023936 +25_2,123,college,right,12.036062849630106,7.081282603445288,82.92114585091079,29.41514389373961,24.52889501282235,3.47470888288631 +25_3,123,college,right,12.67002636206836,6.166220610055859,81.47988892706512,29.495014482436318,23.12732306953214,7.236939070976701 +25_4,123,college,right,11.25288698965717,8.053082307867157,86.23298629059053,29.473959454264957,25.87221099492456,7.4771452799779325 +25_5,123,college,right,11.08617479403052,8.692484952781001,69.26613938797506,25.032022062458367,26.032068366009312,1.0600213353037604 +254_1,73,high_school,right,,,91.56801786559605,39.0726650556056,33.83193427367558,55.19767631179135 +254_2,73,high_school,right,,,107.5870548371847,37.897871029878246,34.75976329523521,49.12290411652925 +254_3,73,high_school,right,,,100.21283577567247,40.404263019792296,35.798743862044255,45.21399896546603 +254_4,73,high_school,right,,,104.71911203025944,35.058912503478695,33.12586896583594,53.86894298917807 +254_5,73,high_school,right,16.521794519849397,-9.468620953160695,96.88305618211895,38.56326299908315,31.219604441324645,50.058100467746655 +254_6,73,high_school,right,,,106.08321241455677,37.16472584477603,31.994624896550626,46.88431305259441 +254_7,73,high_school,right,,,107.8452965991869,37.952681169762,33.18050878591833,45.27588617751724 +254_8,73,high_school,right,,,101.60536464059794,38.625320942726006,34.9984486553328,61.10352091538841 +258_3,127,high_school,right,8.957500877004248,-19.890809491589323,107.77186903617212,33.09283053841463,29.416688786136056,45.358484745383954 +258_5,127,high_school,right,8.711359384871322,-18.905186722979295,118.63533048721378,19.19498496237,26.74136096448526,57.84647528369578 +263_1,53,college,left,12.063969855108427,12.410694104469513,91.70970307405189,30.89827344736443,28.552213938441025,42.733203002324444 +263_2,53,college,left,15.61077093796339,8.143103043115048,94.79869459772272,33.698292531649344,31.48151257399324,44.12125775360447 +263_3,53,college,left,12.439765135420782,10.77507766467923,93.74111812885097,29.819105711207953,28.879511299581882,43.08369268533355 +263_4,53,college,left,14.94063113705396,7.834584370924148,98.12446915398769,30.780212808775275,28.181034895789296,47.877333734305665 +263_5,53,college,left,13.817223534203722,8.744250698470069,93.88454925197958,36.95634978167405,28.7123672671877,36.802220781247 +263_6,53,college,left,13.593645010919456,7.224340296407945,93.5258198582778,31.690244659688943,29.452379525317554,33.844597371182424 +263_7,53,college,left,13.994869262551031,8.477615441204307,95.92984071847225,33.47662908514286,28.158298646566745,36.059647485174736 +263_8,53,college,left,15.26883246666087,8.184375369160676,94.14889404157856,29.044528617724097,26.651854681497593,49.1271618865125 +265_1,44,college,left,20.14984135927398,-1.764520227578089,101.6883153457537,53.63387680174715,27.895895100456993,57.60814631768625 +265_2,44,college,left,22.671259987810778,-2.6027761279882213,117.22939467496037,55.113595570758505,27.500366152010567,48.69901599280449 +265_3,44,college,left,21.087835143331073,-0.5537715625861779,110.76296454233207,57.90986313477235,25.186881163840706,51.14781835111503 +265_4,44,college,left,24.373104557297715,-1.9606989580106529,108.04382617213163,59.22783531559958,29.427643384696875,52.745678872144744 +265_5,44,college,left,20.606175103755426,-4.06924667075026,108.72502690430251,54.85562853643526,32.03179293394985,60.36009294725378 +265_6,44,college,left,19.465367953027933,-1.065474793038959,106.01872346771127,54.480039365717985,26.521037835588835,57.21726327495495 +265_7,44,college,left,22.293682322128532,-1.6275260356756007,109.07591316429689,52.39988742079785,27.472959196792335,56.29150416059071 +265_8,44,college,left,24.172388866272755,-6.464418542299143,102.17206173489856,57.59136795944141,31.079477659742434,51.73679826337845 +268_1,78,college,right,35.17719530934074,3.7960665776190297,115.98248100985535,44.832977405871134,27.38144782657224,32.790034278591655 +268_2,78,college,right,35.214804856279706,3.1409437061250287,109.3565132597777,44.82248505816969,26.558305810372442,44.359977752659425 +268_3,78,college,right,36.66956284612734,1.3894415328905154,115.2333187003669,46.11163463478364,26.60438701426526,32.01002614123253 +268_4,78,college,right,36.83530125586867,2.5113632671630626,115.2177012059898,49.15901089569263,27.775012870017353,34.26720475312636 +268_5,78,college,right,37.55447681525532,2.8834253561250023,115.2449436936572,44.02506416869234,24.539763765625718,29.202079603737882 +268_6,78,college,right,35.972779457634815,3.2000681644090037,113.93769346092178,45.85226578322737,24.811783955410025,28.909749495285002 +268_7,78,college,right,35.51458156871897,1.8185921849232614,113.92582179898793,50.437445199099045,25.64838266368,26.695218152836592 +273_1,130,college,left,8.2585067771658,-11.950227247523856,97.8304929795558,44.83700375260054,24.23164523154788,34.69093909430265 +273_2,130,college,left,8.378287444047547,-12.65724832969056,108.75480337319493,39.25352845190167,26.594458993112948,31.492549410526422 +273_3,130,college,left,10.824925889382133,-14.651102697341571,129.34197202859832,43.54093191252758,30.200937153001245,26.507009850158283 +273_4,130,college,left,9.068689175435267,-10.68344550960856,104.56827697791866,35.228967172380806,29.902352544528135,37.76699691934166 +273_5,130,college,left,10.1047695002546,-9.346844221577214,104.41008950971806,40.95225371237953,26.914902355578793,36.215851651850656 +273_6,130,college,left,,,100.06083044177821,43.237632592187225,26.839470365090456,37.84610968588959 +282_1,80,college,right,16.58209900834309,8.943860624985689,113.9229648216976,51.15793194203579,23.78937794387203,29.90770252012961 +282_2,80,college,right,17.273296214147912,6.879336385115266,113.38244801420174,43.799015072036894,22.21856569209929,27.38315114909572 +282_3,80,college,right,18.667130250465394,6.241633804721545,112.50767480624536,53.189302887822805,25.248871137974888,30.82940469060222 +282_4,80,college,right,17.44850398724001,7.557478571607021,117.9943564817781,49.463701516456425,23.329909132911972,37.47940552721283 +282_5,80,college,right,17.906375026948353,10.504661094263753,118.6065567103051,50.99059097574877,22.804387208633937,30.865983138216805 +282_6,80,college,right,13.390514562964906,12.287726604297006,124.13177142479188,51.961491059773465,23.934110623735744,32.93420055828695 +282_7,80,college,right,18.52803394395943,10.570546379365425,116.96501200701266,42.451357779069625,19.9885094317935,35.144044260376226 +282_8,80,college,right,16.93043664875372,10.526095710046576,123.60860415343313,54.53988907950789,19.78903732248358,28.901982929582022 +283_1,31,college,right,10.552109745610588,-8.419061384518159,94.62338744396253,14.198566017791137,19.425914160399287,42.88019048887858 +283_2,31,college,right,10.711091986946771,-8.292641315358992,90.32868859309886,6.309045253259313,19.723861737432877,42.68029818221828 +283_3,31,college,right,9.238102973938858,-8.902782737616917,88.41020028567507,4.212717212550615,19.1862549116767,38.803883619054574 +283_4,31,college,right,9.60876043792558,-9.378548606516262,87.28734495446453,1.114728433016893,24.57629064663386,42.30991485882672 +283_5,31,college,right,9.07676844072184,-9.111369338941813,100.43131697129435,12.88051100262706,16.493420224393894,45.282186565192745 +283_6,31,college,right,8.51793264299263,-8.310494706594454,83.75256633873582,1.8327248494252615,21.597940549155034,47.39472382837191 +283_7,31,college,right,9.827906041775998,-11.699759657503705,86.24559994367863,4.928269607609991,21.081693146939738,42.27275732837323 +287_1,186,college,right,20.045010920779717,-10.377179530680223,77.33659260630407,26.887568128705766,23.300970672559497,32.049307791670174 +287_2,186,college,right,20.796975589956816,-10.626648035341077,81.30126718406486,33.81783973450098,25.98979454834445,28.183610515956058 +287_3,186,college,right,20.68613740199396,-9.429151219269329,80.3895551279308,26.655920720489007,23.177634612928802,27.356191590594037 +287_5,186,college,right,19.69510519997386,-9.82937291420069,76.14095673654064,36.92275053253067,23.04019928431043,26.98035892406284 +287_6,186,college,right,19.4928137717575,-10.471340341131281,77.01370787441141,28.53398528938456,22.23135242604574,28.858580220222848 +287_7,186,college,right,20.72072019277955,-9.613242780697192,82.64281562002027,35.13388311610325,24.62801194987917,21.55743532346902 +287_8,186,college,right,20.210467279254704,-11.849936668427176,78.8498601931668,18.987353760148608,23.129985953822885,28.503396894456696 +291_1,189,college,right,25.829050177218782,-5.587670587320531,100.73799517654582,22.89454929261268,21.055520655915288,42.242626652240766 +291_2,189,college,right,26.191818341301563,-4.612956159812967,98.6905007244815,22.512855950648287,22.07707793343257,38.061074541370246 +291_3,189,college,right,27.845710195912133,-5.679747447587488,109.81876873442542,24.625036537398472,23.077590270060767,44.57915103521484 +291_4,189,college,right,24.578242498164666,-6.326580948656556,118.12693436139935,25.304873183071408,20.67684105919946,40.305134005130185 +291_5,189,college,right,26.416569218083584,-7.220811764711243,107.33984991836529,25.988547064949586,21.964402647588233,45.92770435342583 +291_6,189,college,right,26.204074840055153,-6.657116929670906,113.01821431476584,31.11771407789604,23.521995269630057,43.658821726668116 +291_7,189,college,right,25.951388616279566,-4.067363882889936,113.62719571772524,23.183225950265296,21.21763329583652,49.835235207435645 +291_8,189,college,right,27.685999040297176,-4.666535212108727,111.87001609187818,31.624321012520312,21.87477863407694,42.084857735614584 +297_1,26,college,right,24.192458718924424,0.8324777675711346,108.83933031139128,33.78762455955193,26.459325316749325,34.20878247548471 +297_2,26,college,right,21.103545963600492,-0.5751305874958348,115.64084332374195,41.14283872240402,23.151323471941208,19.91843842820724 +297_3,26,college,right,21.48143653125156,0.5365370707210957,113.2696352196965,37.41831335865642,23.185467042214693,30.849828239560324 +297_4,26,college,right,22.659495079039836,0.2888355648054528,116.96091337627216,37.14910793773987,27.38883852777255,35.76440349516943 +297_5,26,college,right,29.269828648841695,2.486603703361709,114.375520786206,43.515057411875574,25.387144735706983,30.546808839960697 +297_6,26,college,right,22.17103675825633,-2.4882032885250283,115.7684742403652,36.39498337754419,27.65066303855258,38.67400996181032 +297_7,26,college,right,23.134481518688364,0.3686876272385007,119.41214270161603,33.80017622457419,26.12756610592345,24.729926852604006 +297_8,26,college,right,22.548150158771957,0.5981716052058346,114.95336922754166,44.2829197081784,27.063552434651022,35.91027901695686 +300_1,79,high_school,right,20.238679246817753,-6.475079876583948,99.56924073372912,18.74173531135449,27.10882720132928,48.78441860041652 +300_2,79,high_school,right,22.246793386328108,-8.139574171838063,100.44838763795552,14.519009857910504,27.775306092293857,46.10675947161286 +300_3,79,high_school,right,21.411819140311973,-5.624308985780942,98.8865328071595,12.308540173506685,21.16876022181834,38.26966700011055 +300_4,79,high_school,right,22.21151192991465,-7.472823715788024,98.97976819150792,11.834207499490162,23.889414845040704,46.44452192309131 +300_5,79,high_school,right,21.92230344031388,-5.931271550077611,93.77561235241554,6.3708586465092765,21.571338819666252,39.40481895063946 +300_6,79,high_school,right,20.84020195503983,-6.292700954410634,99.74638026935587,9.836030055931303,19.180881542064917,29.03671089892075 +300_7,79,high_school,right,19.465541997253382,-8.327954250354452,101.88216088079665,15.075265527125765,22.96309373370414,44.59202634759567 +300_8,79,high_school,right,22.91801705692264,-6.410013322489533,99.64673460129625,15.160569647056434,26.49180163120836,52.46403484999148 +302_1,30,college,right,16.86424259562242,-16.43768288682213,95.23999028673323,27.665635654376445,33.861311845167805,55.32902680275352 +302_2,30,college,right,16.938343390738233,-18.00750245749532,92.32550100045574,21.940734470336736,37.96742092933667,57.22125455531418 +302_3,30,college,right,16.996895800387517,-17.610520115912777,102.33775192979492,31.783668168576753,37.60616798018692,53.688317101283154 +302_4,30,college,right,15.889525860070702,-17.486595729631063,94.94360530782187,28.688768613669623,35.572962757774384,65.76221613803347 +302_5,30,college,right,17.014671196570664,-17.983090369555953,98.5931756258705,29.74798466219721,37.5054092902651,53.88548896931813 +302_6,30,college,right,15.647671435699948,-18.06943966399467,101.56232507115833,33.74075154344658,35.32264602261197,50.413828607982246 +302_7,30,college,right,,,103.38357570223917,31.10023146623081,37.71358823257254,54.51704093820358 +302_8,30,college,right,19.180449109939666,-16.94913726278628,103.353681714012,32.40359759591908,36.25224656209622,61.531395271813025 +313_1,90,college,left,24.550094684666252,6.664736442908577,86.18159621303244,32.71052420466569,30.774609294212592,48.919377441158026 +313_2,90,college,left,17.34822863380385,9.407268018680156,81.32955838284872,23.794790481192138,30.59326199615154,42.83874032865589 +313_3,90,college,left,24.2976673353122,8.268956034875146,84.14238717444282,34.817382127059545,32.96949124280009,57.6253310686106 +313_4,90,college,left,17.881830731022262,8.689470946721968,79.65605316511625,30.206164082154515,32.13573297773332,45.71309395665636 +313_5,90,college,left,17.074549591519666,8.617776552423805,88.14939578841206,24.756763684237086,29.156410890917737,44.241477920581985 +313_6,90,college,left,23.99398906161933,6.518017877008305,83.02569263838848,23.540366938972056,28.29155355762007,49.18770046087116 +313_7,90,college,left,25.765393271076338,5.713260247338411,78.85894177478974,29.996866081092122,30.005498996398305,51.51120785475437 +313_8,90,college,left,16.854986410748374,6.839741474858954,79.11951617163638,20.479488233575637,28.983440074801067,44.114252161832056 +320_1,194,college,right,,,103.7986752963013,20.666898097728676,17.167929425430366,20.073646338382737 +320_2,194,college,right,23.639979258758668,-9.087286381716922,105.81585329398564,33.864882769069794,15.91388446137743,28.45968290192801 +320_3,194,college,right,,,109.01969861926462,20.56272135520817,17.75009365960719,11.618226648874321 +320_4,194,college,right,26.00260586586467,-6.766913795917844,107.37554313827629,16.90248108994018,13.252118340871535,11.919831250001536 +320_5,194,college,right,24.023084474771736,-9.208784253992235,104.86745566146001,34.583972020881234,13.68707392680624,28.759230341563228 +320_6,194,college,right,,,106.54221922639334,32.69795634153617,17.512825397310586,34.9845395050068 +320_7,194,college,right,,,109.95255403305508,39.17180747102606,20.236224985855078,27.222469569833525 +320_8,194,college,right,23.286865090179713,-5.768012466949642,95.55223830784674,20.9524042469983,13.089177216217763,10.15830209336874 +321_1,126,high_school,right,,,67.99447790304568,31.551353468446138,30.05554280263387,46.237879717747106 +321_2,126,high_school,right,,,76.41623852097995,38.32048128849132,31.228679207452988,55.919093263564 +321_3,126,high_school,right,,,71.17032433788287,37.94270782307734,33.35045369241551,50.1757690840485 +321_4,126,high_school,right,,,61.099388698659226,30.192001981708017,30.96130740030699,52.227391574018846 +321_5,126,high_school,right,,,76.30074101091235,39.56151717971173,31.466704664326752,49.63124698765896 +321_6,126,high_school,right,17.72794956753642,-19.850019614482903,59.650383811661044,30.1810697451466,31.17206019164923,58.47587517940289 +321_7,126,high_school,right,,,75.23574547471439,32.013748721210334,31.75270353780891,45.7798256164776 +321_8,126,high_school,right,,,68.85476936082951,31.092668359844794,31.964414228125808,51.9530614767478 +324_1,195,college,left,2.4382200818794186,0.5334117444719197,33.39856330773906,8.18268298744539,27.42582423829462,33.967562563163796 +324_2,195,college,left,4.34605287803449,1.3388806447179036,109.0383836922702,27.717974580338137,27.32930001449155,24.66300466697069 +324_3,195,college,left,5.889323242193877,1.0352765321386244,40.153015402132276,11.923029269110373,30.484571164502455,36.05372126753846 +324_4,195,college,left,3.851082825941846,3.124287608246277,35.87926916781233,9.866761654185865,28.708470017675737,30.036077865151075 +324_5,195,college,left,3.5366388820728765,4.515921931914789,83.49326348399539,21.270413419302997,28.460524065939396,35.55270121344099 +324_6,195,college,left,2.7604102964939394,1.3454829943136701,42.1904935397798,10.209626801482017,26.8260529299378,30.073898627028857 +324_7,195,college,left,6.342138340032979,0.10899439180411719,39.08397437021962,2.036512506449583,29.176349365683176,45.921330775610535 +324_8,195,college,left,2.1922056772031553,0.9960439907087277,32.72284889804096,9.739433111792863,27.945210710778294,32.8435428865024 +33_1,139,college,right,17.289496094068614,-11.069820268157969,98.49273822335044,37.10427302667094,14.753178634928435,39.1813168855239 +33_2,139,college,right,15.36919460433921,-11.692897078379815,98.1611654989743,40.00333612855678,15.684494853594394,44.822786975274774 +33_3,139,college,right,14.81951496235611,-12.298408266210686,97.3900173546601,39.32140101035151,13.088369356128572,42.11489704747983 +33_4,139,college,right,18.09048824671267,-12.12972235065888,99.65005757033903,36.83092856999153,14.523571357991706,42.7913967277681 +33_5,139,college,right,14.414914198967912,-13.687551145061207,96.98677613962293,31.833616731774356,14.789027492626051,49.94065657200823 +342_1,200,college,left,20.293548687577157,10.823727531492068,68.08921288077272,32.606147811160454,26.714306704982757,47.42838065349242 +342_2,200,college,left,20.580809870910183,10.803218689008133,61.920553188923044,29.40382268695035,22.948440185415123,36.82713947855793 +342_3,200,college,left,20.76242646588516,10.895146892588173,80.16392807306465,37.75084960120556,20.494982577669226,29.326806122624504 +342_4,200,college,left,20.75135011907148,12.008438495710038,68.19082936200812,36.40682258756428,27.55893214053733,43.41067813143504 +342_5,200,college,left,21.341311995360694,15.502199403137325,63.09299861092638,34.43205835772744,22.03469460397806,30.399668890310867 +342_6,200,college,left,21.219974778060017,11.602419556091519,78.95675299540905,38.287324437329886,23.417521034065338,37.44417588142892 +342_7,200,college,left,20.134245212416026,10.656692228335999,68.60647104569036,36.035731972041646,25.431344733471306,37.1042864994488 +342_8,200,college,left,21.078971159477227,11.529437021817614,87.84197917323866,37.423073667520455,24.409267184546163,39.72650835888242 +343_1,201,college,right,18.65379458980827,-7.81316857756326,113.02975684373449,21.26851655867057,30.054519279351698,29.18850333235064 +343_2,201,college,right,21.606467895741194,-6.72733058584447,119.08263352603166,15.333227766782457,29.857357372612476,31.28383924065218 +343_3,201,college,right,22.061702245744645,-7.115517390472206,117.39175671393109,38.4809854097,26.599839768996674,36.28108815020629 +343_4,201,college,right,22.600196734831968,-8.412171264003433,132.9075713887331,24.261884957748293,33.027104010890845,30.07211846733501 +343_5,201,college,right,23.192642255473945,-8.829370615949273,126.957709721482,16.85269098055187,29.7234446611814,2.9030846373590538 +343_6,201,college,right,23.338986373490275,-9.313672990896237,129.93101220869136,28.632546415567802,29.366360619062643,25.57695312275455 +343_7,201,college,right,23.65018800986403,-4.825607039953411,132.54089108972067,19.492672503136717,29.322491195693257,24.800669305289073 +343_8,201,college,right,21.918668113051318,-8.786046411664273,126.77456460819313,30.83619050443282,27.056902242497088,27.742030609861693 +343_9,201,college,right,22.474317528689422,-7.361419601893942,129.22747376148067,20.0202346834364,28.327972969333256,29.419660214719457 +349_1,121,high_school,right,18.80326679191662,1.8256102375959244,69.56985213609238,15.217702332696547,28.773300854111465,28.844194337723387 +349_3,121,high_school,right,19.027001708346173,3.35012844810484,62.46092723082458,12.967455699783528,29.150291571224457,24.889663700176296 +349_4,121,high_school,right,17.602309514403,2.787989505178075,67.56670598760694,14.639893630165858,27.67135519503744,35.27537578159129 +349_5,121,high_school,right,17.23036433640146,4.616191817571462,64.15394536344908,17.030046235766548,29.58599220277871,30.517674662098916 +349_6,121,high_school,right,18.866798069140135,4.893360043770116,54.81213734537371,8.283505118301179,27.121477853817392,47.0205377254482 +349_7,121,high_school,right,16.683906752606468,1.8923715686098035,54.89385570128079,11.201393806104107,28.53029496477475,32.50161626695752 +349_8,121,high_school,right,19.16285484218661,3.850907485263633,60.529650919547244,11.317668275466758,26.868416070762,30.052188196131297 +350_1,207,high_school,right,16.823385289141065,-20.7596639740201,112.5252002020484,19.20549294357329,25.282149355251107,46.19116937190447 +350_2,207,high_school,right,16.351557314684417,-24.44407906281856,115.77157582787584,23.841964225081824,24.513244080539764,48.190852677878375 +350_4,207,high_school,right,16.917372962164343,-22.911315358648153,110.46171161046652,24.66369901046002,25.262761548134026,51.937934121428675 +350_5,207,high_school,right,17.73181824539625,-23.145013278599436,117.75237244942929,22.229443137250627,23.568582474196635,47.72119721875822 +350_6,207,high_school,right,17.254279426825363,-24.688014475360774,114.0308322163199,18.324052035375132,22.80227177055203,50.57314750223797 +350_7,207,high_school,right,16.690540854763825,-24.058866362293998,111.12019050554095,18.53552172037078,23.437100899943147,51.35658670388616 +350_8,207,high_school,right,17.170897506815773,-22.179394751872792,110.22199847430814,25.958328053892444,22.234631493057783,49.45777110706232 +353_1,98,college,left,19.974121903933558,6.052896589851883,58.36015370053605,23.839923870506368,28.121687096516965,37.92323106675018 +353_2,98,college,left,19.686709401079774,6.125131045366885,52.10720073851421,28.983474984709176,28.493158547085976,49.116540688448914 +353_3,98,college,left,20.332882286778695,3.8869129220430523,57.01031199102912,23.737274750358722,29.938688500713297,33.13330720129942 +353_4,98,college,left,20.237055941885572,4.694134372169259,51.76065279880081,23.524823495558564,28.02196713255478,41.88933663827535 +353_5,98,college,left,19.059964714613173,6.092368721267718,57.59101441148877,28.556167743579834,27.483367131860817,39.64355603977223 +353_6,98,college,left,19.802555291430004,5.385608192561136,55.56295089704228,22.43688510301442,30.058470202369445,44.233391278040294 +353_7,98,college,left,19.463991189212795,4.209006130831966,57.57070416289495,25.8352568786768,27.77249398012595,38.82094592799254 +353_8,98,college,left,19.72249045896731,5.589313582992588,62.30029838377377,29.14000335228124,26.335496872397986,39.18385088540841 +358_1,58,college,left,36.43870861155955,3.4053800774485694,124.69043740412374,57.99692085231746,33.115361069172664,48.060624006568965 +358_3,58,college,left,38.009995691710216,4.491876529855546,129.845718467811,51.52892579425075,31.92504812462792,50.28402864063964 +358_5,58,college,left,37.26487706022414,3.507430523815259,133.97817299033704,59.89579445648246,27.84746806913659,42.77294441505966 +358_6,58,college,left,38.544516427660746,4.033072619546715,137.78914272739104,66.25753433717968,26.056429429090667,41.99145126481327 +358_7,58,college,left,38.395658265853996,4.6302704826046295,132.42875698329652,57.04038814670899,29.984706880535672,45.88159981062443 +358_8,58,college,left,38.43531247022145,2.0981092740709073,133.57909007634998,58.669707951777966,27.782496561319068,42.63075767460159 +36_1,142,college,left,15.738073006605402,-4.8568564554257705,107.75765531866124,44.709243072707494,31.139079866529578,32.13275798631147 +36_2,142,college,left,17.272628627808384,-3.5753026350088533,104.01474202030099,45.02112787262453,29.17775605359318,36.48593362827016 +36_3,142,college,left,18.582224855565947,-5.975303087372737,111.06296171544429,46.069225755031994,30.217234286120977,35.311515956324136 +36_4,142,college,left,16.97932638634693,-6.210200379696374,110.86201483384079,38.08063318651091,27.358587334157423,34.83251134024475 +36_5,142,college,left,17.70268815096011,-6.051021364062251,104.95279605540196,40.891897359224004,32.28890013015697,35.97050900058028 +360_1,210,college,right,17.88199993573707,-6.611322973475694,114.818892981413,6.295692875603521,18.566190677596186,37.78548043285171 +360_2,210,college,right,,,122.98071952943725,7.633269976626423,19.13749966322077,44.379115576711975 +360_3,210,college,right,,,103.74978926369766,20.032166735152686,20.10702648084344,44.942244887116516 +360_4,210,college,right,16.81055441478785,-6.855209937220934,104.5882326848829,23.206248265975773,20.53650388223174,40.94774941902899 +360_5,210,college,right,17.646780227958175,-7.077839474612574,119.24269924374717,8.501627884050095,18.127131742974786,31.824552320549483 +360_6,210,college,right,18.55587515176108,-7.612599458210752,100.59737573407747,15.323862984209882,20.515212880428393,46.401905112814084 +360_7,210,college,right,19.225051837104047,-6.538933707852038,106.33810344805418,2.9627729865872254,19.155373783658856,50.218226549533895 +360_8,210,college,right,22.541139570006337,-4.919551670111076,95.06135866670046,27.705237359376426,19.118408106033424,33.44545198451602 +363_1,34,college,right,,,102.90712037508584,28.58407710901733,28.40240228351235,29.66808995916462 +363_2,34,college,right,,,102.54896643064122,23.91106510828304,29.907970090647243,30.505665392696912 +363_3,34,college,right,,,100.6438015580746,24.485772062233977,28.378941715726867,28.300510990042973 +363_4,34,college,right,11.821656479063453,-4.928282696525315,105.15922824652556,31.42381162933188,32.49557423311068,32.19863273343977 +363_5,34,college,right,10.910948396288408,-4.269308005557207,106.43852555023102,34.92057814181163,29.8370844856952,32.74260117146909 +363_6,34,college,right,12.480332768626452,-6.049903591698495,112.09187146600105,32.07477327562299,29.228407148582907,28.55963852935809 +363_7,34,college,right,11.882947312864998,-5.574012106801888,109.58358612073121,34.796570516497965,29.665390646376586,42.934241106710154 +363_8,34,college,right,11.941352914355141,-4.390695331318966,94.78833840062241,26.993915153077438,25.028000520126977,49.04672109674934 +376_1,215,college,right,9.522428265336801,-7.29627032552645,93.51153902691512,37.45648608373605,24.8974824741024,12.585100344082756 +376_2,215,college,right,10.872892019818801,-4.57315681790385,97.20480206700094,34.786685067585495,24.68269409888851,23.848959041878388 +376_3,215,college,right,10.370881627464527,-2.856647270440959,98.54004344106927,40.683317258304015,21.952574519992908,16.925787857119957 +376_4,215,college,right,10.780410723981706,-4.1227246717994035,90.66906680026598,37.78886414550715,24.530202603385078,8.208311498535114 +376_6,215,college,right,10.401822990784941,-4.7451194279230435,101.07542940431755,37.653447110834634,23.519916828189285,8.82850700513144 +376_7,215,college,right,11.590280312442495,-3.4838474578952514,97.31376978354115,36.57301218293878,26.429214175498803,12.440125467011836 +376_8,215,college,right,11.52573592600261,-4.644995217312896,99.80698266584281,40.13377332591105,24.97724347328165,11.229375832216633 +378_1,57,college,right,21.57400523469004,-6.401916582563331,125.71539435595113,23.895793643206503,22.17345215003263,30.97569037963464 +378_2,57,college,right,21.91080338880767,-9.127087499717788,117.88713639818468,24.073247033898014,25.76560339970121,37.04198351480066 +378_3,57,college,right,22.198496857536067,-8.40638880245757,126.24987779713616,28.518446901906515,24.137163703353366,38.678872585203 +378_4,57,college,right,23.644250581753038,-8.218049858165699,117.85286190333164,14.494346200329261,25.57747403815451,39.426609657284985 +378_5,57,college,right,,,121.76819295894833,20.233540861416827,25.725802782758326,42.80788217123084 +378_6,57,college,right,21.61652708570107,-8.29199428221554,117.56710639941451,27.63675250318323,24.477493190147385,31.98880114117808 +378_7,57,college,right,,,121.91896488971867,25.771527766601594,23.30526739702968,33.285790959181924 +383_1,94,college,left,8.556376757442768,1.1748242708764565,99.60341768915191,32.70934188073221,30.583029003699735,47.01905102481367 +383_2,94,college,left,8.438720762883328,-0.8941654744679965,99.0714222502532,35.589861979992065,29.443658399725688,46.07099064467648 +383_3,94,college,left,7.905848864186291,1.2198597979415524,101.85020934508577,34.394216282580544,30.09714826277491,48.941809427054274 +383_4,94,college,left,7.576809979072923,-0.021242576456813822,106.53791357378974,32.935117988240535,31.97324602093964,52.20333871078431 +383_5,94,college,left,8.377768118634403,-0.011134497995954007,102.61913250090875,34.76327866156183,31.169492275731276,50.1490065078847 +383_6,94,college,left,7.751469724677564,2.242038872623283,103.09305854423607,36.26060865061251,31.73969484640631,45.88040249673611 +383_7,94,college,left,8.670005303881107,1.333040145458142,98.2480871460359,33.80308848681736,30.010876177979355,54.13062810334619 +383_8,94,college,left,8.646297380759217,-1.125118281584946,106.78624472433641,32.63261965226354,32.03150166698487,48.06140084018507 +391_1,103,high_school,right,18.811269094121542,-0.9171489702413851,96.8111715821315,48.33636627526636,28.86030805295261,36.142194418762585 +391_2,103,high_school,right,17.096068910092203,-3.4032114527753095,97.3713799435737,48.149223196833844,31.140432767929884,30.810647281538756 +391_3,103,high_school,right,18.910747122409454,-2.4136120942078776,100.16780021630241,46.3021403255772,28.413282486156223,31.285271187655752 +391_4,103,high_school,right,15.683165356213374,-3.520517925874657,95.87080672113943,45.70841934678663,30.01489175244915,27.936979440736305 +391_5,103,high_school,right,19.34948076601979,-2.154314856444472,103.94932558570186,50.0976387992456,29.05154379840442,31.021383173833975 +391_6,103,high_school,right,17.8708499404767,-2.324813756577754,95.89538951997602,45.723732812820174,30.544848393152325,39.985461372671764 +391_7,103,high_school,right,20.080550374920808,-1.7933527899953958,102.29845588611728,50.46710376553993,28.81376684609701,38.483971499369574 +391_8,103,high_school,right,18.261310180673156,-2.3438880412036553,99.89923224731706,47.32732795386673,30.596304370221453,33.742323716575676 +396_1,74,college,right,11.112846958268243,-15.400155491364103,101.86241851530298,34.353235527263365,25.211183701903256,42.415632785074465 +396_2,74,college,right,,,106.16716251722335,34.05555062339329,23.100224436024682,40.195044428655166 +396_3,74,college,right,,,92.29671631176025,34.53976766752828,25.99669607352289,48.09015595397962 +396_4,74,college,right,13.616324578552398,-13.123720970458663,101.6808448564423,34.623041040524015,24.817749645204593,36.84366965333747 +396_5,74,college,right,12.01655464509877,-16.35326931710756,96.39707943175644,29.67792179064233,23.855677348177718,46.16720130864219 +396_6,74,college,right,12.890556655506773,-16.007090188701454,98.39379007045858,32.28413605909972,22.3183015519246,42.848157011386014 +396_7,74,college,right,12.317874659146574,-11.172118653788317,99.0514052929517,28.6316763768543,18.993368674631153,37.3607621532607 +396_8,74,college,right,12.815923305587171,-11.33693888897983,94.71670671847727,27.721586348360432,21.227552010104972,37.266426163615264 +398_1,221,college,left,18.69765114787429,1.5824797890220168,102.86531832831717,12.945117257391786,35.74093615691245,45.15836035416754 +398_2,221,college,left,22.284122811217042,4.785432221937157,94.18508175709418,18.228936210921745,33.623837811737985,48.020334854998175 +398_3,221,college,left,16.285436467281226,6.335567544458854,97.32082077809369,10.690784500591178,34.42851850701895,35.00337176899687 +398_4,221,college,left,15.498363280398141,8.162382829626694,98.966614549947,16.703798803342977,35.20392952321991,31.475722245885216 +398_5,221,college,left,13.496374240521117,3.8017145368865215,106.46105711651727,12.37700501359322,36.47507035949035,47.88371234555366 +398_6,221,college,left,15.09459542662786,3.6570478368894044,94.17389245014789,16.466648132041144,32.43843867837952,38.37809555269429 +398_7,221,college,left,12.070480278450695,2.3271621646703977,97.63346774360447,15.652070883815611,37.66574949352953,50.67720686384946 +42_1,145,college,right,11.1531458727249,-6.00256582009186,103.50121283227077,42.23089108674273,26.963599822474198,36.33015462048121 +42_2,145,college,right,11.241585108624697,-7.543352999561165,97.49677676231968,36.13266945062739,27.880073950538147,40.18787838048111 +42_3,145,college,right,11.797107220080425,-5.206815030373178,99.29411792312737,38.18420799643167,29.834351982397713,39.14118030473736 +42_4,145,college,right,10.785050497524091,-8.74203678264496,99.76108110634107,34.87212912774706,32.350431835317764,42.00103157451398 +42_5,145,college,right,10.263584795463457,-9.17327570361374,101.14595687104881,35.27934501986866,32.53911951434233,50.056807336160965 +426_1,231,college,right,21.132807447662742,-6.292093090691992,89.30405516052575,23.615104673765245,27.230646295520142,45.889505444588465 +426_2,231,college,right,20.21668829958614,-3.8295218483134192,90.43312205971199,23.043390815875483,28.985158468073656,37.14552199362682 +426_3,231,college,right,20.610541509954704,-5.172967889202113,93.54668874178816,25.371589301577217,27.811100164618693,41.86326126121357 +426_4,231,college,right,22.32558324252619,-5.339977466211167,97.58172908363099,23.717138455821797,28.332631572698425,41.86145652812414 +426_5,231,college,right,21.353611846519637,-5.827837742801819,96.22244890156072,24.404040983791617,26.63839938547494,37.73965429680276 +426_6,231,college,right,21.78031666204448,-5.927501326671944,93.42889048104725,26.2382429890975,27.007991146557487,38.563667729666264 +426_7,231,college,right,20.952064034259465,-6.124578168659269,100.69968465578843,25.62341134887393,24.791302024344695,43.09697292548453 +426_8,231,college,right,18.842010887728552,-7.165720936459849,104.16864209361015,27.87120176243093,23.5604431007815,37.868443614849646 +43_1,146,college,right,22.37205668638525,-3.9558057559291058,88.23086433030748,26.719559868422266,21.952983508026232,37.819576027629594 +43_2,146,college,right,18.470920592131066,-7.974432179194423,88.94223020647647,24.21195525164194,19.362239818825127,34.29101610213861 +43_3,146,college,right,17.79807982508296,-8.791739596127059,91.92587966308666,24.206659526228123,20.223782139266174,34.28496500225634 +43_4,146,college,right,18.26446627091834,-9.779306663456396,98.95093922469616,19.7753164709859,20.788245731451777,29.90022870388966 +440_1,238,college,left,14.015097103126852,4.836142306812604,92.51146139271577,5.3669148408246485,28.075221322568474,40.843025679061725 +440_2,238,college,left,14.530834228292107,0.4264807557440804,99.7944140433039,45.11880881728378,22.418821786705315,44.82707667031111 +440_3,238,college,left,,,99.1148117397299,4.81234471705443,28.655162723135298,46.39347245042974 +440_4,238,college,left,12.62200570330439,5.964857410428948,108.77288584288712,44.876700246610184,21.52406988449972,37.02301650288199 +440_5,238,college,left,18.496837358024745,6.1244124741254495,113.9184290696987,5.934912652387737,21.506839143396547,43.599398507109825 +440_6,238,college,left,14.705147415233506,4.498410857856925,100.93534757445461,29.190745425008544,29.41475824935642,51.07591001297761 +440_7,238,college,left,,,105.02190967965278,21.711536460448798,21.409048768917117,41.933323589438736 +440_8,238,college,left,16.791257155034327,5.294727280742876,106.2732249073841,18.471125470832447,26.3951416436337,45.081242642837346 +447_1,242,pro,right,13.315715832547784,-4.449185381097095,92.36828393567416,24.625103437745963,23.399430525324416,36.82164167006558 +447_2,242,pro,right,13.157103894627072,-2.96829588216292,94.35218345429172,30.35602345698993,24.972570204655092,48.61622162694288 +447_3,242,pro,right,12.001693981969066,-3.537788705608591,90.34233312140032,16.621321491875193,27.86871786283457,44.092522299203274 +447_4,242,pro,right,,,96.22021463508537,26.93902991580677,27.741652809173058,56.51168924657888 +447_5,242,pro,right,12.857010117784686,-2.0759072350553254,96.02008157197818,26.628829790744334,23.225764213196396,40.53496968198626 +447_6,242,pro,right,,,89.41582650004794,25.836595035054557,25.371942752033615,54.23884076355884 +447_7,242,pro,right,13.599724870154464,-6.9981661711354946,93.69397116790049,28.36968861214882,29.031887200889418,54.72112927578144 +447_8,242,pro,right,13.572585079553892,-5.6100481584110184,91.35601621915224,27.02887305570593,27.021066268353906,49.14369874143767 +448_1,243,pro,right,11.546138003083858,-6.112513443084367,80.93083898291796,41.45430030238276,33.08995428140026,49.887270925865096 +448_2,243,pro,right,11.477995549754109,-5.836359014756567,86.8850949188758,41.01445627485961,36.08279035488528,64.74116074948486 +448_3,243,pro,right,12.063201445984697,-5.672835906023096,89.50029531478903,42.36345381101168,37.20611777226965,48.03181429775346 +448_4,243,pro,right,11.420480313152048,-5.855768073904159,84.6489074133434,44.012426193175514,33.71919483433418,59.27370777676779 +448_5,243,pro,right,11.357088707366874,-5.311590663038345,90.0321080430006,39.91674864375162,34.352610271704606,56.81910858361083 +448_6,243,pro,right,10.469560272072748,-5.69230976016587,90.45317271801606,40.20089819446855,34.20615328690514,50.71046267688157 +448_7,243,pro,right,10.487546087299812,-5.155580929251386,91.06044544746568,40.43282641035404,39.74473020801846,58.25425306731031 +448_8,243,pro,right,12.460351807202494,-7.946191498969341,87.7099303863655,38.59931985390418,36.16440036006742,59.67632858253255 +45_1,147,college,right,13.195491350681344,-23.320700794771938,85.89851143275163,37.72934992408841,31.627106481112065,50.1569316376664 +45_2,147,college,right,12.775508769858941,-24.036096514741757,100.00866282119982,30.33431290729797,29.489103910911528,38.64762391540427 +45_3,147,college,right,11.802604427437604,-22.584868515865992,94.86937839929756,30.53486922296716,29.39345040391675,43.74070896057294 +45_4,147,college,right,12.412194200626192,-23.025699098602445,89.82918496615444,29.195753876662593,28.12535944078481,43.44689218145502 +45_5,147,college,right,11.969590164813008,-24.163600722167985,97.09239464418822,31.055489324210924,27.05353919591091,38.859127924390755 +450_1,209,college,right,24.323395103404433,-14.4952229422546,113.71014315629496,28.060432574235946,19.01614010220811,35.39810380490663 +450_2,209,college,right,23.535018375671203,-15.693427169080422,115.54343492681471,25.286184171205434,18.396085599814782,33.598520585016715 +450_3,209,college,right,23.35902301270557,-15.603981545530587,110.33714259631742,23.915421476443825,19.15137160445707,39.90807483523924 +450_4,209,college,right,3.225702568334964,-14.941154366403907,112.18603068331052,30.26595055590822,17.106689860945924,42.63682798619796 +450_5,209,college,right,24.305370544277473,-14.105577882895659,116.3412175336593,28.70032025216804,21.600239001417346,37.790429759184406 +450_6,209,college,right,23.703809787069073,-15.041278117760072,109.93168330698641,28.782797326108025,18.67604789914513,39.57572365358026 +450_7,209,college,right,23.15976324421136,-14.233123302611858,111.2412591116194,30.301386520011718,17.724789880133347,41.353572732660815 +450_8,209,college,right,22.821713311691802,-15.525034091582768,112.6155142089573,27.014710064668066,19.31007019406179,45.51647317337806 +451_1,70,college,right,8.321929030071058,-14.923017276289528,91.02353551353454,32.63884427378426,20.938329324986817,40.064168510399874 +451_2,70,college,right,7.8192542913127205,-14.456220088060434,97.07155369918964,34.967244245895586,22.545031595315706,39.16560701167499 +451_3,70,college,right,8.930806623164637,-15.881047806631784,93.36829098562531,38.04942374179501,20.1001871837843,34.59222991227591 +451_4,70,college,right,8.62881867459445,-14.513089102566425,94.90963006308748,36.113495039558444,20.8415082170404,42.415300282396856 +451_5,70,college,right,7.940713916276751,-16.20772264880864,94.0408621803069,36.193616225089784,21.33413014922065,42.62754840974552 +451_6,70,college,right,9.548209614706163,-15.42288920292765,104.74362588047403,39.40810049397152,21.377362339408943,34.62546249577534 +451_7,70,college,right,8.998578235024763,-15.096680597532043,97.17681862073775,39.517767827832444,20.52688069927087,40.46478197811136 +451_8,70,college,right,8.257439294764325,-14.708263762192871,97.9340263218282,42.19851150311692,15.159440931706833,35.80402440251308 +468_1,108,college,right,10.110536488429101,-5.310094960504955,124.96638258127307,38.31374750484137,32.514493680406524,35.35254251304337 +468_2,108,college,right,9.770806246200952,-4.240309921055001,124.99063519555598,37.14954910133636,30.706556502522908,34.59531439386491 +468_3,108,college,right,10.500407520804192,-4.22915366116402,123.61786233915612,24.873673001417473,29.876633293606,30.652768572538218 +468_4,108,college,right,10.890674334041634,-4.708224269775229,120.39006951490978,25.921806208861994,30.39162521303613,33.585590555782055 +468_5,108,college,right,10.941016544041865,-5.17407848333724,119.62307993203363,26.461387983116026,31.108781779448694,40.01379892193351 +468_6,108,college,right,10.657950336822639,-5.094590405644169,114.49933987271172,34.922097781073305,28.04080477971515,43.79801256102696 +468_7,108,college,right,7.155098989278343,-5.0250645807867045,123.23675175221906,25.200890657218622,30.749235329749585,34.5614304421654 +468_8,108,college,right,10.941310766109416,-5.625566171139951,125.05796543739334,22.31336826021021,30.987774849558715,31.266242227530586 +47_1,149,college,right,18.850598681738575,-7.463479562312813,115.16152385013326,28.854702077595462,25.755611104933756,33.51992246225116 +47_2,149,college,right,16.84010158415039,-7.711403798889677,106.80516249919191,24.81355145028752,28.63811905932764,42.42540950032435 +47_3,149,college,right,18.97419089062716,-8.256643196273075,107.97232374732117,18.824419405797755,31.656494620542553,46.73584191720831 +47_4,149,college,right,18.482041484400863,-7.990836689784118,100.99926569618701,9.318538489416852,29.525152474864203,29.064749107035777 +47_5,149,college,right,21.254419112804793,-7.269265015320599,109.24805390767821,30.543625004334473,30.219893683155156,33.49766174478022 +474_1,50,college,right,17.59775768415831,-6.806565303769219,93.88738342177776,33.16185721337351,24.992041972948968,37.08532246845372 +474_2,50,college,right,19.08482778992643,-6.247189422887857,98.07629847397904,34.769517309483035,22.79982601880972,20.784579936073012 +474_3,50,college,right,18.245732049927152,-7.14748578707821,92.66757432002903,32.891001064278555,25.673388823737074,39.063120707566085 +474_4,50,college,right,19.13211696705157,-5.521757391507407,97.06491090908325,33.2723508582809,21.057388674300135,29.534119234386317 +474_5,50,college,right,19.213215924861704,-4.761242005259788,91.99842740809915,29.454541068574457,27.202802655210593,33.02849229539006 +474_6,50,college,right,18.59192931328691,-6.453193186086622,94.6766231546328,34.89449726884615,24.804670264860185,30.52864427249901 +474_7,50,college,right,19.30930877615998,-4.79193440266053,91.66494372420574,31.620572346720593,24.181739407713557,37.119130470938856 +474_8,50,college,right,18.900346604007787,-3.892439599937518,96.03015345995149,32.19559264231603,22.861437864226613,37.528384993064655 +478_1,137,pro,right,20.738487134866542,-5.194219379738087,107.89458511208493,39.234754095260655,27.914183610332373,50.220033888869494 +478_2,137,pro,right,20.314403749717528,-4.852812761137187,111.40339608925606,38.4088566128392,26.260535467660112,46.11561572547661 +478_3,137,pro,right,20.282156950418564,-5.2698406291169135,104.7988920144622,39.3188886901568,28.269682334003903,49.561423713500034 +478_4,137,pro,right,20.67317192214788,-4.256787177402401,109.5943420106968,37.579036367942024,29.1716224669574,47.091765129056974 +478_5,137,pro,right,19.819650638859635,-5.476074439408677,112.2628780538692,38.82336727615083,29.530049656419585,53.9339700236131 +478_6,137,pro,right,21.18145355485907,-5.794361306611222,111.02749019545742,38.92773132992605,26.597069380304454,48.61235463655213 +478_7,137,pro,right,20.30731557056503,-4.739836067164305,111.114971859565,40.08656917201202,28.949949709706633,47.34635164818818 +48_1,150,college,right,26.575187567450875,-13.571228991600748,94.00943278074284,41.08240401717315,30.531077226570357,62.34412581274842 +48_2,150,college,right,26.427099445576847,-17.125515452326482,105.04417515830015,44.5802381485974,32.06979975555277,46.809129484159996 +48_4,150,college,right,25.866645791962906,-14.361336294600733,110.73702999503888,44.76523897688969,29.966419214153298,49.19806847455927 +48_5,150,college,right,24.667527477803745,-13.406268172830067,112.47189843824883,45.63427711560172,27.781301420598712,44.49243570035605 +490_1,128,college,left,31.374688891262345,-2.4152911029334803,103.27601861826192,32.974629582527314,35.915789338330804,29.63819338498036 +490_2,128,college,left,30.894798715193204,-0.633159922758864,113.30505470370946,28.987985332573928,34.14128618151379,28.679340838232026 +490_3,128,college,left,31.1542062558607,0.7815354964004371,118.01708022719978,37.8580458271926,33.28146208945118,37.81320292387358 +490_4,128,college,left,27.40716711272099,-3.6884669817263216,115.50730333223414,29.790572084120313,30.714491516965445,28.69611842229338 +490_5,128,college,left,27.203624838609894,-1.7956100417628704,113.63382747024319,25.08384581749897,32.680400819345806,29.823410795236303 +490_6,128,college,left,23.87347124119503,-0.11467329977125473,109.41934510552046,27.33005474640933,31.37243925862093,27.737246533869556 +490_7,128,college,left,24.792013627539816,-0.6392775775582038,112.45353366128901,29.108875155821423,32.859998653545205,29.560600512507342 +490_8,128,college,left,29.216270845841194,-2.776524487548272,110.41231290997173,29.15716730088002,31.006530649946082,33.12716367903256 +492_1,192,college,right,18.648927000070863,-10.11760019466476,108.09414527935458,32.04928214648967,24.94827963654784,38.84187669126714 +492_2,192,college,right,21.657989717747903,-10.81158792629165,106.92120813099211,35.42225749082593,25.690002945870134,49.8471165496342 +492_3,192,college,right,19.423155946950942,-10.090318951825424,107.65273580766436,34.75454544698033,23.874693558471048,46.538353410602355 +492_4,192,college,right,21.07290661743599,-9.64108033092947,120.0353600688776,35.58143003531151,25.03037471441177,45.499767342137794 +492_5,192,college,right,19.104820733057757,-8.958916557486077,109.48147540935022,34.349241048515296,25.37098763921963,51.317680046020996 +492_6,192,college,right,17.795660945981346,-9.533068352967774,118.11898433096206,35.514090481740425,22.5263715351252,39.96542633864655 +492_7,192,college,right,20.16647768787116,-10.62941927433178,126.47797216017655,26.21181141746908,26.81815440940326,43.747659200360175 +492_8,192,college,right,17.676117213759458,-8.944482501910159,123.54062363133204,37.81609990869467,19.518718089423114,36.66436095148578 +500_1,193,college,right,19.77381107136258,-9.722859609580269,110.38447836072802,8.0129849667224,20.648160568750885,24.582522939736396 +500_2,193,college,right,21.33920301507188,-8.018158575032203,111.2141885750424,9.013541685018183,25.645465298985464,43.19281313072567 +500_3,193,college,right,16.962705238976547,-8.841437138087144,111.93879819122728,-3.4180049022178736,18.203016458672632,41.72886466296098 +500_4,193,college,right,20.16541948998745,-8.762373067496014,104.2077526793846,12.314097232073351,24.264505583939922,41.810212075995864 +500_5,193,college,right,20.32783443968317,-7.7539349554405135,113.85459334061973,1.078324563450309,19.430594827648605,38.1549147718021 +500_6,193,college,right,17.824978733832825,-8.844605155356106,104.36484615470233,13.05486795563003,24.140441275803706,46.95942601290696 +500_7,193,college,right,18.516529592927064,-8.240310406532899,126.42064444891646,-6.059102371837724,18.01613224279918,31.792927823230478 +500_8,193,college,right,19.632230133643095,-8.195594617499978,113.746520543672,2.3203797691912627,18.012630520404134,28.12172385759673 +504_1,49,college,left,,,91.46664313690165,24.37911095175548,17.831138668233343,51.58707641462503 +504_2,49,college,left,9.798524197425005,5.7503926963999845,87.41983262250531,25.89397236597415,15.760848929244945,55.99797417635821 +504_3,49,college,left,9.954613283705068,7.170808882951974,85.97357671226557,14.564964498883597,19.54552831459083,59.37046457381673 +504_4,49,college,left,10.85231638834367,5.615832036963553,91.73407074504769,21.847115717612155,17.041943621683544,60.27659787860825 +504_5,49,college,left,9.10169462123071,7.0985882573803565,97.96905062578755,35.342059953246206,15.835460815382262,55.843183396096286 +504_6,49,college,left,,,91.81605672881227,34.032156046239635,18.447566746064737,55.77944122020066 +504_7,49,college,left,9.994026719760507,5.867495104331283,98.73799389965987,34.01520959810753,16.804490044619996,52.313572365130916 +504_8,49,college,left,8.730361390277427,8.226123923222417,101.73049756920646,38.645499165341334,20.13044164214061,56.60557098528325 +509_1,222,pro,right,12.389468250837275,-16.985890636839258,110.06184430367881,22.431197815541907,31.20564179593769,59.03000657313098 +509_2,222,pro,right,12.453658732246957,-22.27326128116394,129.48157974336485,21.305044520923843,30.92472663917775,48.284483247765344 +509_3,222,pro,right,13.18105036329394,-17.31643443688739,111.21936470261548,27.666581313996033,32.36583271372925,55.21063470382427 +509_4,222,pro,right,15.041089787917134,-17.029420393862154,108.45200117720799,26.904646965549688,30.043156881839447,60.37572872928721 +509_5,222,pro,right,15.335801699298637,-18.563175332412612,106.5588664003681,23.90526547582718,32.456671093121976,62.306021030655224 +509_6,222,pro,right,13.410632170546608,-20.427231414586572,107.01578566563443,30.807459545889685,30.05761449835729,57.90882039202161 +509_7,222,pro,right,15.585886725392887,-16.712477081039395,109.66648112645694,21.980277833345497,31.80155384907499,62.25799183079372 +509_8,222,pro,right,14.957875854837987,-20.169887978290916,117.70551600410509,32.38600100669885,29.316199653411402,54.3565666542822 +51_1,151,college,left,14.596225789640915,-1.5903033280846728,108.74853541308345,30.440038886045016,27.06735706598255,42.65303450081797 +51_2,151,college,left,14.955737476901964,-0.7397314781666182,122.72963267015355,26.246200427572404,27.30070380358551,30.480662217204543 +51_3,151,college,left,14.068505358640282,0.07003763895764337,126.35490711175967,20.07820890926908,27.133754064108235,36.78532423825396 +51_4,151,college,left,13.779673789220945,-2.8541581254345374,128.92081875083565,20.80434289973067,25.958303285495408,42.33987684214601 +51_5,151,college,left,15.269584115253133,-2.3450663057876397,146.00972207915623,32.646628329325665,26.63899435399528,15.869886674699016 +56_1,152,college,left,21.073018355084844,7.182777899093793,85.89994306024906,32.08142211595327,29.533835418839644,67.82739068302209 +56_2,152,college,left,19.63429334928401,7.016971448077555,87.84655939604295,37.92883026749237,30.48975278600981,58.3526693287123 +56_3,152,college,left,21.075102704705294,8.314351847713056,92.11209259602856,42.26134305096855,31.700339212470784,66.48839885969421 +56_4,152,college,left,20.91168644777435,8.077579818380684,99.91584493326408,37.170084740931586,28.337307613407074,57.33657758427436 +56_5,152,college,left,20.639143108571343,10.19184995392294,96.03389042512744,39.2664590994756,29.867124103726077,60.33447169108667 +59_1,157,college,right,21.23704709814964,0.3797410555340832,120.91003157576317,33.666492964839165,30.36915880641273,23.27499669028356 +59_2,157,college,right,21.441437859918548,0.43984674497309584,102.27480329461359,40.288518383268524,32.95932851319119,20.536348881549067 +59_3,157,college,right,21.300600450082133,2.4122481471377455,118.73375059141327,38.324619938309496,29.979175592963767,24.79213620296282 +59_4,157,college,right,19.266642129638,4.1502515597247225,117.64658723272231,32.20587394387647,30.179253540123828,36.4086358331577 +59_5,157,college,right,20.271645024667105,2.9438041427333133,118.06984455808887,28.671393386040762,27.830254116629675,30.603394472406677 +6_1,5,pro,right,20.153733207983908,-0.6922160436634499,104.38770238476197,14.737424131072174,22.76469415444318,38.84132600955171 +6_2,5,pro,right,,,104.80577104859019,23.231295432141508,25.0347519045478,40.71871375485362 +6_3,5,pro,right,,,104.55356357533744,24.886563241647792,26.03574134349316,43.719905804752926 +6_4,5,pro,right,,,106.57926700983846,33.1610336268044,23.52525991502283,30.35150589670445 +6_5,5,pro,right,,,104.64879197688497,32.31365546680803,24.89594742220525,37.63072592192366 +67_1,162,high_school,right,27.956471373460577,-7.607458643822355,82.34563285668271,25.90785603878254,28.494562362341213,44.66945501038803 +67_2,162,high_school,right,29.388195452406944,-6.7541111909047515,88.20483788028977,27.21477809720767,23.447302917196552,25.101326106987134 +67_3,162,high_school,right,28.985665072329287,-7.910033298288084,87.3139438423595,31.362215645703856,23.767469421628416,25.70215465672267 +67_4,162,high_school,right,28.276387965178206,-8.157601423259308,78.11188694933077,25.628118269379343,25.279894674663527,40.94793164049361 +67_5,162,high_school,right,29.54891511767193,-8.043641254972755,86.10021665836342,27.625877095467132,23.820415683381395,33.45799604400509 +68_1,163,college,right,13.989109806584175,-15.829762009683805,87.34652800194401,23.85265553704599,25.12385878105104,63.53153607008193 +68_2,163,college,right,11.31350545779063,-16.536342977682693,88.23620293274264,28.868620047578304,23.523533798889954,61.5722406600733 +68_3,163,college,right,13.535157180188948,-16.02825064043168,88.05056134428884,23.770661640856844,23.764389799106066,66.97015655949566 +68_4,163,college,right,13.68621808513679,-15.265041560890495,86.26032286754769,24.914044883547717,25.839446608821646,65.79981301758103 +68_5,163,college,right,13.335130294403175,-16.54264856399584,93.0078130711085,26.7390218208283,24.706434323711225,66.47279883361334 +69_1,164,college,right,17.128695566679813,-11.194652967242348,80.69493336409926,40.03986720330377,25.430648256258557,57.274464961867565 +69_2,164,college,right,17.218251120213264,-12.208875705024298,81.79311238080136,40.602306220937095,24.590438480128284,49.15035050099143 +69_3,164,college,right,16.445631154546493,-10.184486081837633,81.7027210806737,42.545866865856624,24.871155750180375,49.29869409148303 +69_4,164,college,right,16.436038231197124,-13.108880928185215,82.0196845106536,40.68141411600425,27.73461449498523,52.02591623194653 +69_5,164,college,right,17.392670516402838,-13.931236388200176,82.01655237475092,42.324319124112606,24.23219112297516,51.2857358187263 +72_1,8,college,right,19.07165109275541,-6.208063938927182,110.458965185278,20.692343346410013,29.190321674088064,33.446369509208914 +72_3,8,college,right,18.02556892156686,-7.8136121425062015,101.6904877265958,29.72998965997533,27.606795274604107,52.271040817682874 +72_4,8,college,right,16.986560290774673,-8.043063679587732,97.79975424993714,19.25446148148825,25.75627230244784,40.07436027549062 +72_5,8,college,right,18.827847476791067,-5.759296991284742,91.76578675212136,24.723297398295273,23.870391350700213,45.25292102195503 +73_1,167,high_school,right,27.315905860211476,-3.949850552491881,89.75117487811119,18.977911218000997,24.85197090644252,19.808469174312975 +73_2,167,high_school,right,26.003680089612622,-4.593443115578168,98.30237350819566,24.940611181660472,26.41692367746199,16.395942612100264 +73_3,167,high_school,right,27.509598625425355,-4.812890071734159,94.6260170321824,9.898410610666815,27.272931337294153,15.20257818836739 +73_4,167,high_school,right,28.538953430529556,-5.824139247522993,99.5476512638519,26.87909104527614,25.47790957800067,13.929931350160846 +73_5,167,high_school,right,26.973271381977728,-5.826572494780692,102.14473901262573,22.812839211039318,27.695619074614342,18.264535883688968 +8_1,174,pro,left,16.621292421677612,7.450020467884656,97.19570137781955,43.59930739930908,27.87895480131453,24.217942317001064 +8_2,174,pro,left,17.04673467388326,5.546829530787619,99.062312171645,43.05777199391429,27.590438386021596,23.233639551718536 +8_3,174,pro,left,16.460947226165736,6.322179145415419,103.32069583025711,39.85544011894049,25.87361610436195,19.74696454985811 +8_4,174,pro,left,18.17292428250778,2.075009134355497,100.36630152862584,43.586830593859275,29.070545024595543,24.99574612865411 +8_5,174,pro,left,17.40372468161158,4.465880827816193,102.08774262719135,41.323414591086845,29.708612712360285,28.097063286148448 +81_1,176,college,right,15.230644673522766,-10.787690397088795,112.68683840085032,-4.9291747054778625,20.353668673078964,34.244973342629415 +81_2,176,college,right,13.294155159757723,-9.511762912861059,97.4626499273402,7.882714668006599,20.443511637052552,40.94073284412046 +81_3,176,college,right,15.243004621887943,-12.418502599749104,107.74062939324331,14.696376104790858,21.59666297599388,42.73608432763475 +81_4,176,college,right,15.865417573102873,-16.854627960084258,111.56787171273076,1.1851460818846817,22.741174354448518,44.54155560241357 +81_5,176,college,right,15.025797584394669,-9.872618384789575,109.5597840646438,-0.41424620510852606,23.97504313329323,41.31142038467701 +84_1,177,pro,left,14.16031464896101,6.519518504672817,108.59829513412711,23.81748815775535,30.657321237014564,23.692849430393977 +84_2,177,pro,left,14.462470557211944,4.5144511640326925,108.99288980040299,25.185648369582736,30.280706871270468,25.85831252381163 +84_3,177,pro,left,15.373485599464308,4.70946535886435,104.7473341176808,29.414193166726562,31.906394314912767,38.010929453059056 +84_4,177,pro,left,16.221590244318843,6.700942890141789,108.64130619489606,27.757717121318308,32.08120346467579,35.22114785945483 +84_5,177,pro,left,15.80738312126215,5.195672297375495,113.92129034226994,27.391333057266053,30.083511973479204,26.76675728593823 +86_1,178,college,right,20.186775331827338,6.217638381553115,82.3502060928311,18.311621795799823,30.966790742875553,5.114208505099994 +86_2,178,college,right,21.606032091690174,5.589871508858636,72.09199918731181,19.307861205770706,31.908593271221566,25.891422311320433 +86_3,178,college,right,22.81898422120032,8.505229337511992,69.19913908141797,16.333123846508812,31.46993755759883,24.975608696043235 +86_4,178,college,right,21.077699222477587,5.966032237796554,59.04462655789966,18.74287468225819,34.77473211242664,15.684131488404937 +86_5,178,college,right,22.61511188438566,6.074706861238042,77.96748537352023,14.939935839112252,31.571450050870432,25.112079116782347 +89_1,179,pro,right,6.502142331511949,-5.63661740031651,110.43590660737352,38.061150446879324,29.415137331099764,44.28965323820115 +89_2,179,pro,right,9.912697999272595,-8.853735474584681,109.71187539356566,37.25486849543074,30.569514917955434,52.142845483307745 +89_3,179,pro,right,8.514904952189742,-7.929292452155778,109.85204442360057,30.906916346373265,31.05272337081437,48.1010639204453 +89_4,179,pro,right,9.998143043696318,-7.757994092363873,112.32078193592399,34.18501020142206,28.801443037203967,49.12523591433667 +89_5,179,pro,right,8.199715842838255,-5.839256035389866,109.8303286472401,32.37249221621681,26.839366701451777,40.70205451436213 diff --git a/data_ref/scripts/compute_contract_v1_1_benchmarks.py b/data_ref/scripts/compute_contract_v1_1_benchmarks.py new file mode 100644 index 0000000000000000000000000000000000000000..10bba73be9212940c1eb57853d7ddd1841f93ab5 --- /dev/null +++ b/data_ref/scripts/compute_contract_v1_1_benchmarks.py @@ -0,0 +1,106 @@ +"""Generate matching 3D reference intervals for the six additional coach metrics. + +Run from the repository root with landmarks.csv, metadata.csv and an output directory. +Uses OBP dataset-v1 (360 Hz), first force-plate touch (fp_10_time), the existing +v1 stride-start rule, and the first 100 ms after contact. Athlete medians, then +population percentiles, avoid giving prolific athletes disproportionate weight. +The intervals describe this laboratory population; they are not ideal targets. +""" +import argparse +import hashlib +import json +from pathlib import Path + +import numpy as np +import pandas as pd + +from baseball_batting.coach_geometry import ( + EXTENDED_METRICS, follow_through_frame, inclination, knee_angle, rotation_amount, +) + + +def compute(landmarks, metadata): + joints = ('left_hip', 'right_hip', 'lsjc', 'rsjc', 'lkjc', 'rkjc', 'lajc', 'rajc') + columns = ['session_swing', 'time', 'fp_10_time', 'contact_time'] + columns += [f'{j}_{axis}' for j in joints for axis in 'xyz'] + data = pd.read_csv(landmarks, usecols=columns) + meta = pd.read_csv(metadata).set_index('session_swing') + levels = {'high_school': 'high_school', 'college': 'college', 'independent': 'pro', 'milb': 'pro'} + rows = [] + for swing, g in data.groupby('session_swing', sort=False): + if swing not in meta.index: + continue + g = g.sort_values('time'); m = meta.loc[swing]; t = g.time.to_numpy() + fd, ct = g.fp_10_time.iloc[0], g.contact_time.iloc[0] + if not np.isfinite([fd, ct]).all() or fd >= ct: + continue + landing, contact = (int(np.argmin(abs(t - v))) for v in (fd, ct)) + if landing >= contact: + continue + p = {j: g[[f'{j}_{axis}' for axis in 'xyz']].rolling(5, center=True, min_periods=1).mean().to_numpy() + for j in joints} + lead = 'l' if m.hitter_side == 'R' else 'r' + speed = np.linalg.norm(np.gradient(p[lead + 'ajc'][:, :2], t, axis=0), axis=1) + need = max(1, round(.1 / np.median(np.diff(t)))) + start = None; run = 0 + for i in range(landing, -1, -1): + run = run + 1 if speed[i] < .15 else 0 + if run >= need: + start = i + need - 1 + break + h = p['right_hip'] - p['left_hip']; s = p['rsjc'] - p['lsjc'] + hip_heading = np.degrees(np.arctan2(h[:, 1], h[:, 0])) + shoulder_heading = np.degrees(np.arctan2(s[:, 1], s[:, 0])) + separation = (shoulder_heading - hip_heading + 180) % 360 - 180 + lean = inclination((p['left_hip'] + p['right_hip']) / 2, (p['lsjc'] + p['rsjc']) / 2, [0, 0, 1]) + knee = knee_angle(p['left_hip' if lead == 'l' else 'right_hip'], p[lead + 'kjc'], p[lead + 'ajc']) + finish = follow_through_frame(t, contact, len(t) - 1) + rows.append({ + 'session_swing': swing, 'user': m.user, 'level': levels.get(m.highest_playing_level), + 'batting_hand': 'right' if m.hitter_side == 'R' else 'left', + 'torso_inclination_at_stride_start': lean[start] if start is not None else np.nan, + 'hip_shoulder_separation_at_stride_start': separation[start] if start is not None else np.nan, + 'pelvis_rotation_to_contact': rotation_amount(hip_heading, landing, contact), + 'lead_knee_extension_to_contact': knee[contact] - knee[landing], + 'torso_inclination_at_contact': lean[contact], + 'shoulder_rotation_after_contact': rotation_amount(shoulder_heading, contact, finish), + }) + return pd.DataFrame(rows) + + +def aggregates(rows): + result = {} + for metric in EXTENDED_METRICS: + result[metric] = {} + for hand in ('right', 'left'): + for level in ('high_school', 'college', 'pro'): + group = rows[(rows.batting_hand == hand) & (rows.level == level)] + values = group.groupby('user')[metric].median().dropna() + cell = {'n_athletes': len(values), 'n_swings': int(group[metric].notna().sum())} + if len(values) >= 5: + cell.update({f'p{p}': round(float(np.percentile(values, p)), 3) for p in (10, 25, 50, 75, 90)}) + result[metric][f'{hand}/{level}'] = cell + return result + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('landmarks', type=Path); parser.add_argument('metadata', type=Path) + parser.add_argument('output', type=Path) + args = parser.parse_args(); args.output.mkdir(parents=True, exist_ok=True) + rows = compute(args.landmarks, args.metadata) + result = {'source': 'OpenBiomechanics dataset-v1; hitting_landmarks.zip', + 'source_url': 'https://github.com/drivelineresearch/openbiomechanics/releases/tag/dataset-v1', + 'landmarks_sha256': hashlib.sha256(args.landmarks.read_bytes()).hexdigest(), + 'metadata_sha256': hashlib.sha256(args.metadata.read_bytes()).hexdigest(), + 'n_swings': len(rows), 'n_athletes': int(rows.user.nunique()), + 'definition_version': '1.1', 'follow_through_seconds': .1, + 'limitations': 'Laboratory reference intervals, not ideal technique or validated phone-video accuracy.', + 'metrics': aggregates(rows)} + (args.output / 'contract_v1_1_benchmarks.json').write_text(json.dumps(result, indent=2) + '\n') + rows.to_csv(args.output / 'contract_v1_1_swings.csv', index=False) + print(json.dumps({k: result[k] for k in ('n_swings', 'n_athletes', 'landmarks_sha256')})) + + +if __name__ == '__main__': + main() diff --git a/docs/motion-coach-payload-v1.1.example.json b/docs/motion-coach-payload-v1.1.example.json new file mode 100644 index 0000000000000000000000000000000000000000..f6b0b3787abe24a1ad4f1db1aea6454f6679d186 --- /dev/null +++ b/docs/motion-coach-payload-v1.1.example.json @@ -0,0 +1,257 @@ +{ + "schema_version": "1.1", + "measurement_definitions_version": "1.1", + "analysis_id": "synthetic-contract-example", + "analysis_revision": 1, + "swing_id": "synthetic-contract-example:swing_1", + "status": "completed", + "athlete": { + "athlete_id": "fixture", + "batting_hand": "right", + "lead_foot": "left", + "age_years": null, + "height_cm": null + }, + "context": { + "sport": "baseball", + "practice_type": "tee" + }, + "events": { + "stride_start": { + "video_time_s": 0.1, + "capture_time_s": 0.1, + "status": "limited", + "source": "manual_review", + "reasons": [ + "event_timing_uncertain" + ], + "source_frame_index": 3 + }, + "front_foot_down": { + "video_time_s": 0.3333333333333333, + "capture_time_s": 0.3333333333333333, + "status": "limited", + "source": "manual_review", + "reasons": [ + "event_timing_uncertain" + ], + "source_frame_index": 10 + }, + "contact": { + "video_time_s": 0.6666666666666666, + "capture_time_s": 0.6666666666666666, + "status": "limited", + "source": "manual_review", + "reasons": [ + "event_timing_uncertain" + ], + "source_frame_index": 20 + }, + "follow_through": { + "video_time_s": 0.7666666666666667, + "capture_time_s": 0.7666666666666667, + "status": "limited", + "source": "derived_from_contact", + "reasons": [ + "event_timing_uncertain" + ], + "source_frame_index": 23 + } + }, + "measurements": [ + { + "value": 0.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 0.0, + "upper": 0.0, + "source": "adjacent_event_frames" + }, + "metric_id": "hip_shoulder_separation_at_foot_down", + "group": "stride", + "unit": "deg", + "reference": "signed_horizontal_shoulder_minus_hip_heading", + "event_id": "front_foot_down" + }, + { + "value": 21.868, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "scale_is_model_estimated", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 15.663143066406192, + "upper": 28.01344366270865, + "source": "adjacent_event_frames" + }, + "metric_id": "stride_relative_length", + "group": "stride", + "unit": "cm", + "reference": "lead_ankle_displacement_relative_to_rear_ankle", + "start_event_id": "stride_start", + "end_event_id": "front_foot_down" + }, + { + "value": 0.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 0.0, + "upper": 0.0, + "source": "adjacent_event_frames" + }, + "metric_id": "hip_shoulder_separation_at_contact", + "group": "contact_follow_through", + "unit": "deg", + "reference": "signed_horizontal_shoulder_minus_hip_heading", + "event_id": "contact" + }, + { + "value": 0.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 0.0, + "upper": 0.0, + "source": "adjacent_event_frames" + }, + "metric_id": "torso_inclination_at_stride_start", + "group": "balance_load", + "unit": "deg", + "reference": "torso_angle_from_vertical", + "event_id": "stride_start" + }, + { + "value": 0.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 0.0, + "upper": 0.0, + "source": "adjacent_event_frames" + }, + "metric_id": "hip_shoulder_separation_at_stride_start", + "group": "balance_load", + "unit": "deg", + "reference": "signed_horizontal_shoulder_minus_hip_heading", + "event_id": "stride_start" + }, + { + "value": 30.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 24.000000000000007, + "upper": 36.0, + "source": "adjacent_event_frames" + }, + "metric_id": "pelvis_rotation_to_contact", + "group": "power_move", + "unit": "deg", + "reference": "absolute_net_horizontal_rotation", + "start_event_id": "front_foot_down", + "end_event_id": "contact" + }, + { + "value": 0.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 0.0, + "upper": 0.0, + "source": "adjacent_event_frames" + }, + "metric_id": "lead_knee_extension_to_contact", + "group": "power_move", + "unit": "deg", + "reference": "change_in_3d_lead_knee_angle", + "start_event_id": "front_foot_down", + "end_event_id": "contact" + }, + { + "value": 0.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 0.0, + "upper": 0.0, + "source": "adjacent_event_frames" + }, + "metric_id": "torso_inclination_at_contact", + "group": "contact_follow_through", + "unit": "deg", + "reference": "torso_angle_from_vertical", + "event_id": "contact" + }, + { + "value": 9.0, + "status": "limited", + "confidence": null, + "uses_interpolated_input": false, + "reasons": [ + "event_timing_uncertain", + "model_accuracy_unvalidated" + ], + "benchmark": null, + "value_interval": { + "lower": 3.0000000000000044, + "upper": 14.99999999999999, + "source": "adjacent_event_frames" + }, + "metric_id": "shoulder_rotation_after_contact", + "group": "contact_follow_through", + "unit": "deg", + "reference": "absolute_net_horizontal_rotation", + "start_event_id": "contact", + "end_event_id": "follow_through" + } + ] +} diff --git a/docs/motion-coach-payload.schema.json b/docs/motion-coach-payload.schema.json index f57e690113d3efaf0f6dcdef1d42a0889d8a62f9..8a0bdd40ce1aa1ab74d3536e6566e4ed38220d5c 100644 --- a/docs/motion-coach-payload.schema.json +++ b/docs/motion-coach-payload.schema.json @@ -145,7 +145,8 @@ "enum": [ "manual_review", "pose_estimated", - "bat_ball_detector" + "bat_ball_detector", + "derived_from_contact" ], "type": "string" }, @@ -171,12 +172,28 @@ "scale_unknown", "excessive_interpolation", "occlusion_unresolved", - "temporal_inconsistency" + "temporal_inconsistency", + "capture_time_unknown", + "follow_through_not_recorded", + "model_accuracy_unvalidated" ], "type": "string" }, "title": "Reasons", "type": "array" + }, + "source_frame_index": { + "anyOf": [ + { + "minimum": 0, + "type": "integer" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Source Frame Index" } }, "required": [ @@ -200,6 +217,17 @@ }, "contact": { "$ref": "#/$defs/CoachEvent" + }, + "follow_through": { + "anyOf": [ + { + "$ref": "#/$defs/CoachEvent" + }, + { + "type": "null" + } + ], + "default": null } }, "required": [ @@ -210,6 +238,187 @@ "title": "CoachEvents", "type": "object" }, + "ExtendedMeasurement": { + "additionalProperties": false, + "properties": { + "value": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Value" + }, + "status": { + "enum": [ + "available", + "limited", + "unavailable" + ], + "title": "Status", + "type": "string" + }, + "confidence": { + "anyOf": [ + { + "maximum": 1, + "minimum": 0, + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Confidence" + }, + "uses_interpolated_input": { + "title": "Uses Interpolated Input", + "type": "boolean" + }, + "reasons": { + "items": { + "enum": [ + "contact_not_verified", + "contact_not_applicable", + "event_not_detected", + "event_timing_uncertain", + "required_event_unavailable", + "required_event_limited", + "lead_foot_unknown", + "required_landmarks_unusable", + "ground_plane_unknown", + "scale_is_model_estimated", + "scale_unknown", + "excessive_interpolation", + "occlusion_unresolved", + "temporal_inconsistency", + "capture_time_unknown", + "follow_through_not_recorded", + "model_accuracy_unvalidated" + ], + "type": "string" + }, + "title": "Reasons", + "type": "array" + }, + "benchmark": { + "default": null, + "title": "Benchmark", + "type": "null" + }, + "value_interval": { + "anyOf": [ + { + "$ref": "#/$defs/ValueInterval" + }, + { + "type": "null" + } + ], + "default": null + }, + "metric_id": { + "enum": [ + "torso_inclination_at_stride_start", + "hip_shoulder_separation_at_stride_start", + "pelvis_rotation_to_contact", + "lead_knee_extension_to_contact", + "torso_inclination_at_contact", + "shoulder_rotation_after_contact" + ], + "title": "Metric Id", + "type": "string" + }, + "group": { + "enum": [ + "balance_load", + "power_move", + "contact_follow_through" + ], + "title": "Group", + "type": "string" + }, + "unit": { + "const": "deg", + "default": "deg", + "title": "Unit", + "type": "string" + }, + "reference": { + "enum": [ + "torso_angle_from_vertical", + "signed_horizontal_shoulder_minus_hip_heading", + "absolute_net_horizontal_rotation", + "change_in_3d_lead_knee_angle" + ], + "title": "Reference", + "type": "string" + }, + "event_id": { + "anyOf": [ + { + "enum": [ + "stride_start", + "contact" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Event Id" + }, + "start_event_id": { + "anyOf": [ + { + "enum": [ + "front_foot_down", + "contact" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "Start Event Id" + }, + "end_event_id": { + "anyOf": [ + { + "enum": [ + "contact", + "follow_through" + ], + "type": "string" + }, + { + "type": "null" + } + ], + "default": null, + "title": "End Event Id" + } + }, + "required": [ + "value", + "status", + "confidence", + "uses_interpolated_input", + "reasons", + "metric_id", + "group", + "reference" + ], + "title": "ExtendedMeasurement", + "type": "object" + }, "RelativeStride": { "additionalProperties": false, "properties": { @@ -267,7 +476,10 @@ "scale_unknown", "excessive_interpolation", "occlusion_unresolved", - "temporal_inconsistency" + "temporal_inconsistency", + "capture_time_unknown", + "follow_through_not_recorded", + "model_accuracy_unvalidated" ], "type": "string" }, @@ -279,6 +491,17 @@ "title": "Benchmark", "type": "null" }, + "value_interval": { + "anyOf": [ + { + "$ref": "#/$defs/ValueInterval" + }, + { + "type": "null" + } + ], + "default": null + }, "metric_id": { "const": "stride_relative_length", "default": "stride_relative_length", @@ -384,7 +607,10 @@ "scale_unknown", "excessive_interpolation", "occlusion_unresolved", - "temporal_inconsistency" + "temporal_inconsistency", + "capture_time_unknown", + "follow_through_not_recorded", + "model_accuracy_unvalidated" ], "type": "string" }, @@ -396,6 +622,17 @@ "title": "Benchmark", "type": "null" }, + "value_interval": { + "anyOf": [ + { + "$ref": "#/$defs/ValueInterval" + }, + { + "type": "null" + } + ], + "default": null + }, "metric_id": { "const": "hip_shoulder_separation_at_contact", "default": "hip_shoulder_separation_at_contact", @@ -495,7 +732,10 @@ "scale_unknown", "excessive_interpolation", "occlusion_unresolved", - "temporal_inconsistency" + "temporal_inconsistency", + "capture_time_unknown", + "follow_through_not_recorded", + "model_accuracy_unvalidated" ], "type": "string" }, @@ -507,6 +747,17 @@ "title": "Benchmark", "type": "null" }, + "value_interval": { + "anyOf": [ + { + "$ref": "#/$defs/ValueInterval" + }, + { + "type": "null" + } + ], + "default": null + }, "metric_id": { "const": "hip_shoulder_separation_at_foot_down", "default": "hip_shoulder_separation_at_foot_down", @@ -547,19 +798,50 @@ ], "title": "SeparationAtFootDown", "type": "object" + }, + "ValueInterval": { + "additionalProperties": false, + "properties": { + "lower": { + "title": "Lower", + "type": "number" + }, + "upper": { + "title": "Upper", + "type": "number" + }, + "source": { + "const": "adjacent_event_frames", + "default": "adjacent_event_frames", + "title": "Source", + "type": "string" + } + }, + "required": [ + "lower", + "upper" + ], + "title": "ValueInterval", + "type": "object" } }, "additionalProperties": false, "properties": { "schema_version": { - "const": "1.0", - "default": "1.0", + "default": "1.1", + "enum": [ + "1.0", + "1.1" + ], "title": "Schema Version", "type": "string" }, "measurement_definitions_version": { - "const": "1.0", - "default": "1.0", + "default": "1.1", + "enum": [ + "1.0", + "1.1" + ], "title": "Measurement Definitions Version", "type": "string" }, @@ -604,10 +886,13 @@ }, { "$ref": "#/$defs/SeparationAtContact" + }, + { + "$ref": "#/$defs/ExtendedMeasurement" } ] }, - "maxItems": 3, + "maxItems": 9, "minItems": 3, "title": "Measurements", "type": "array" diff --git a/docs/motion-coach-v1.1.md b/docs/motion-coach-v1.1.md new file mode 100644 index 0000000000000000000000000000000000000000..810cc8d982d2dfa001197af298178e6d05f21ea9 --- /dev/null +++ b/docs/motion-coach-v1.1.md @@ -0,0 +1,61 @@ +# Motion measurements and coaching: contract 1.1 + +The engine exports nine measurements across the four report groups. The receiver still accepts stored 1.0 payloads with exactly three measurements. It never invents missing measurements for an old payload. Report JSON remains version 1.0 with additive `value_interval` and `score_interval` fields on each measurement. + +The three original metrics and their definitions are unchanged. All measurements derived from the current video pose models carry `model_accuracy_unvalidated` and are marked limited. A successful job or a passing geometry test does not establish physical accuracy of the reconstructed body. + +## Measurements + +| Group | Measurement | Exact definition | +| --- | --- | --- | +| Balance and Load | Torso inclination at stride start | Angle of hip-centre to shoulder-centre vector from fixed vertical | +| Balance and Load | Hip–shoulder separation at stride start | Wrapped signed horizontal shoulder heading minus hip heading | +| Stride | Hip–shoulder separation at foot down | Same heading difference at first visible ground touch | +| Stride | Relative stride length | Horizontal change of lead ankle relative to rear ankle between stride start and foot down, in centimetres | +| Power Move | Pelvis rotation to contact | Magnitude of net unwrapped horizontal hip rotation from foot down to contact | +| Power Move | Lead knee extension to contact | Change in 3D hip–knee–ankle angle between foot down and contact; positive means straightening | +| Contact and Follow-Through | Hip–shoulder separation at contact | Same signed heading difference at marked contact | +| Contact and Follow-Through | Torso inclination at contact | Same torso angle at contact | +| Contact and Follow-Through | Shoulder rotation after contact | Magnitude of net horizontal shoulder rotation from contact to the original sample nearest 100 ms later | + +The group names are navigation labels. These measurements do not establish balance forces, energy transfer, bat speed, ball flight, or the quality of the entire follow-through. The last metric covers only an early shoulder turn. It requires a known physical capture clock and a clip extending at least 100 ms past contact. + +## Events and quality + +Usable 1.1 events include the exact zero-based `source_frame_index` into decoded original frames. Manual marks remain `manual_review` with `event_timing_uncertain`; they are not automatic detections or force-plate measurements. The derived follow-through event uses `derived_from_contact`. An unavailable event has null times, source and frame index, plus reasons. + +The backend saves revised marks and the report together using these frame indices. It does not infer frames by multiplying timestamps by FPS, and it preserves existing marks for old payloads without frame indices. + +The existing landmark, vertical-reference, interpolation, scale and camera checks still apply. Slow background drift is now checked against an anchor image as well as consecutive images. Three corroborating anchor displacements above the larger of 1% of image size or three times the adjacent-motion threshold contradict a fixed-camera declaration. Unsigned per-frame movement is never summed, so tracking noise cannot accumulate into a false drift estimate. This is an image-motion diagnostic, not camera calibration. A caller's original declaration is retained in the request; conflicting evidence changes the effective analysis status. + +## Scores and advice + +The references describe recorded athletes, not ideal technique or guaranteed performance. Each metric uses the existing percentile-distance score. Group scores average rated metrics, including limited metrics; overall score averages rated groups. Limited inputs make their scores tentative. Missing groups are explicitly listed, and partial coverage adds a warning explaining the overall score's denominator. + +Where neighboring samples are usable, `value_interval` spans evaluations with event marks shifted by one source frame in either direction. The coach computes `score_interval` across that range, including scoring breakpoints. These are event-sensitivity bounds, **not** confidence intervals or bounds on total model error. Missing neighboring evidence or a signed-angle wrap prevents publishing a misleading linear interval. A range that changes rating category or spans at least 20 score points cannot determine the corrective focus or a technique tip. + +Unknown drill context and dry swings receive descriptions of the reference comparisons, without technique corrections. Their text is deterministic, so a language model cannot turn a walk-through drill into an instruction to shorten the stride. Conflicting profile and payload batting sides also suppress technique advice and add `batting_hand_conflict`; scores still identify which analysis side was used. The engine does not infer batting side from video. + +For supported coaching contexts, generated wording is checked for measured scope, retained uncertainty, rating direction and unsupported physical claims. Rejected fields use deterministic text. A contact angle alone cannot justify a claim about follow-through; the early shoulder-turn metric cannot justify a claim about the whole finish. + +## Reference data and reproducibility + +The six added references come from [OpenBiomechanics dataset-v1](https://github.com/drivelineresearch/openbiomechanics/releases/tag/dataset-v1), using its 3D hitting landmarks and athlete metadata. Source attribution and licensing are described in the [OpenBiomechanics repository](https://github.com/drivelineresearch/openbiomechanics). Derived files retain that source's attribution and share-alike/noncommercial licensing terms. + +`data_ref/scripts/compute_contract_v1_1_benchmarks.py` uses the same geometry functions as the engine, the existing five-sample smoothing and final still-ankle stride-start rule, first force-plate touch (`fp_10_time`), and recorded contact time. It calculates per-athlete medians before population percentiles, requires at least five athletes per reference cell, and records source file hashes. The present extraction contains 649 swings from 97 athletes. Matching formulas do not validate phone-video pose accuracy or eliminate laboratory-versus-video event differences. + +From the repository root, with the official release landmarks and metadata available: + +```sh +PYTHONPATH=. python data_ref/scripts/compute_contract_v1_1_benchmarks.py /path/to/landmarks.csv /path/to/metadata.csv data_ref/calibration/contract_v1_1 +python AI-coach-agent/tools/build_benchmarks.py +python AI-coach-agent/tools/build_benchmarks.py --check +``` + +The generator requires pandas. Large raw landmark files and user videos are not checked into the repository. The [synthetic payload example](motion-coach-payload-v1.1.example.json) demonstrates shape and geometry, not a measured human swing. + +## Delivery and deployment + +Submission still consists of a `video` multipart part and one `options` JSON part. No new client options are required. `/v1/motion-analyses/{job_id}/coach-payload` returns the stored immutable bytes, so HTTP size and SHA-256 match the artifact manifest. Old payloads are returned unchanged rather than reserialized with new defaults. + +Deploy the receiver that accepts both versions before serving 1.1 engine results. GitHub Actions deploys the backend and the Hugging Face Space from `main`; verify backend success before allowing the engine rollout to finish. Existing stored reports remain immutable for their analysis revision; higher revisions rebuild them under the new rules. The mobile app is outside this change. diff --git a/tests/test_coach_contract_v1_1.py b/tests/test_coach_contract_v1_1.py new file mode 100644 index 0000000000000000000000000000000000000000..9bb2bcb4aa3e1f6aae7a6e7baa973c3c47096074 --- /dev/null +++ b/tests/test_coach_contract_v1_1.py @@ -0,0 +1,121 @@ +"""Analytic geometry, missing evidence, old-contract compatibility and live QA regressions.""" +import json +from pathlib import Path + +import numpy as np +import pytest + +from ai_coach.config import Settings +from ai_coach.swing_report import AthleteContext, build_report, validate_payload +from baseball_batting.coach_geometry import inclination, knee_angle, rotation_amount +from baseball_batting.motion_coach import build_coach_payload +from baseball_batting.motion_contract import MotionInput +from baseball_batting.motion_refine import static_camera_conflict +from test_sam_batting import pose + + +def fixture_payload(*, hand='right', clock=True, camera='fixed_verified', transform=None): + n = 31; p = pose(n); times = np.arange(n) / 30 + for i in range(n): + a = np.radians(3 * i) + matrix = np.array([[np.cos(a), 0, -np.sin(a)], [0, 1, 0], [np.sin(a), 0, np.cos(a)]]) + p[i] = p[i] @ matrix.T + up = np.array([0., -1., 0.]) + if transform is not None: + p = p @ transform.T; up = transform @ up + corrected = {'points_relative': p, 'valid': np.isfinite(p).all(-1), + 'boundary': np.zeros((n, 70), bool), 'interpolated': np.zeros((n, 70), bool)} + opts = MotionInput(single_swing=True, camera_stability=camera, up_vector=up.tolist(), + up_source='Synthetic known vertical', handedness=hand, + athlete={'athlete_id': 'fixture', 'batting_hand': hand}, context={'practice_type': 'tee'}, + contact_frame=20, windows=[{'start_frame': 0, 'end_frame': 30, 'stride_start_frame': 3, 'landing_frame': 10}]) + return build_coach_payload(opts, {'analysis_id': 'fixture', 'analysis_revision': 1}, corrected, times, + times if clock else np.full(n, np.nan), []).model_dump(mode='json') + + +def test_extended_measurements_have_analytic_values_and_all_groups_score(): + p = fixture_payload(); parsed, problems = validate_payload(p) + assert parsed is not None and not problems + rows = {m['metric_id']: m for m in p['measurements']} + assert len(rows) == 9 and p['schema_version'] == '1.1' + assert rows['pelvis_rotation_to_contact']['value'] == pytest.approx(30) + assert rows['shoulder_rotation_after_contact']['value'] == pytest.approx(9) + assert rows['torso_inclination_at_stride_start']['value'] == pytest.approx(0) + assert rows['lead_knee_extension_to_contact']['value'] == pytest.approx(0) + assert p['events']['follow_through']['source_frame_index'] == 23 + assert p['events']['follow_through']['source'] == 'derived_from_contact' + report = build_report(p, AthleteContext(level='college'), settings=Settings(_env_file=None, google_api_key=None)) + assert len(report['groups']) == 4 + assert all(g['metric_ids'] and g['score'] is not None for g in report['groups']) + assert all(m['rating_is_tentative'] for m in report['measurements']) + for row in rows.values(): + assert row['value_interval']['lower'] <= row['value'] <= row['value_interval']['upper'] + + +def test_geometry_does_not_depend_on_camera_axes_or_batting_hand_sign_for_rotation_amount(): + a = .7; r = np.array([[1, 0, 0], [0, np.cos(a), -np.sin(a)], [0, np.sin(a), np.cos(a)]]) + base = fixture_payload(); rotated = fixture_payload(transform=r); left = fixture_payload(hand='left') + for x, y in zip(base['measurements'], rotated['measurements']): + assert y['value'] == pytest.approx(x['value'], abs=.001) + assert next(m for m in left['measurements'] if m['metric_id'] == 'pelvis_rotation_to_contact')['value'] == 30 + assert knee_angle(np.array([0, 1, 0]), np.array([0, 0, 0]), np.array([1, 0, 0])) == pytest.approx(90) + assert inclination([0, 0, 0], [1, 0, 1], [0, 0, 1]) == pytest.approx(45) + assert rotation_amount([170, 179, -175, -160], 0, 3) == pytest.approx(30) + + +def test_unknown_clock_blocks_only_timed_follow_through_and_moving_camera_blocks_pose_comparisons(): + p = fixture_payload(clock=False) + assert not validate_payload(p)[1] + unavailable = [m for m in p['measurements'] if m['value'] is None] + assert len(unavailable) == 1 and unavailable[0]['metric_id'] == 'shoulder_rotation_after_contact' + assert 'capture_time_unknown' in unavailable[0]['reasons'] + moving = fixture_payload(camera='moving') + assert all(m['value'] is None for m in moving['measurements']) + + +def test_old_three_metric_payload_still_builds_without_inventing_new_values(): + p = json.loads((Path(__file__).parents[1] / 'docs/motion-coach-payload.example.json').read_text()) + assert p['schema_version'] == '1.0' and not validate_payload(p)[1] + report = build_report(p, settings=Settings(_env_file=None, google_api_key=None)) + assert len(report['measurements']) == 3 + assert {g['group'] for g in report['groups'] if not g['metric_ids']} == {'balance_load', 'power_move'} + assert report['meta']['input_schema_version'] == '1.0' + + +def test_slow_camera_drift_is_not_lost_and_unsigned_jitter_is_not_accumulated(): + assert static_camera_conflict({'background_displacement_image_fraction': [.001] * 100, + 'background_anchor_displacement_image_fraction': [.002, .008, .015, .025, .04]}, .003) + assert not static_camera_conflict({'background_displacement_image_fraction': [.001] * 1000, + 'background_anchor_displacement_image_fraction': [.001] * 125}, .003) + assert not static_camera_conflict({'background_displacement_image_fraction': [np.nan] * 4}, .003) + + +def test_unknown_drill_does_not_prescribe_a_shorter_stride_and_frame_sensitivity_is_visible(): + p = fixture_payload(); p['context']['practice_type'] = 'unknown' + row = next(m for m in p['measurements'] if m['metric_id'] == 'stride_relative_length') + row['value'] = 97.597; row['value_interval'] = {'lower': 89.3, 'upper': 102.7, 'source': 'adjacent_event_frames'} + contact = next(m for m in p['measurements'] if m['metric_id'] == 'hip_shoulder_separation_at_contact') + contact['value'] = -7.575 + contact['value_interval'] = {'lower': -16.126, 'upper': -2.142, 'source': 'adjacent_event_frames'} + p['athlete']['batting_hand'] = 'left'; p['athlete']['lead_foot'] = 'right' + report = build_report(p, AthleteContext(level='college'), settings=Settings(_env_file=None, google_api_key=None)) + contact = next(m for m in report['measurements'] if m['metric_id'] == 'hip_shoulder_separation_at_contact') + assert contact['score'] == 79 and contact['score_interval'] == {'lower': 0, 'upper': 100} + assert report['focus_area']['kind'] == 'general' + assert all(m['coach_tip'] is None for m in report['measurements']) + assert 'shorten' not in report['focus_area']['coach_message'].lower() + assert {'practice_context_unverified', 'event_sensitive_scores'} <= {x['code'] for x in report['data_quality']} + + +def test_contract_does_not_accept_an_interval_that_excludes_its_value(): + p = fixture_payload(); p['measurements'][0]['value_interval']['lower'] = 100 + assert validate_payload(p)[0] is None + + +def test_contradictory_source_frames_and_missing_follow_through_clock_are_rejected(): + p = fixture_payload() + p['events']['contact']['source_frame_index'] = 9 + assert 'events.front_foot_down.source_frame_index' in validate_payload(p)[1] + p = fixture_payload() + p['events']['follow_through']['capture_time_s'] = None + assert 'events.follow_through.capture_time_s' in validate_payload(p)[1] diff --git a/tests/test_motion_coach.py b/tests/test_motion_coach.py index 32370f7aa72799507d5bb2a9878ae06cfb4c76d9..d8bc38548fb829525fa396b96993bc7f7c62bf08 100644 --- a/tests/test_motion_coach.py +++ b/tests/test_motion_coach.py @@ -1,4 +1,5 @@ """Contract compatibility, exact event sampling and immutable delivery; no model accuracy claim.""" +import hashlib import json from pathlib import Path import numpy as np @@ -65,11 +66,11 @@ def test_exact_selected_frames_relative_stride_and_receiver_contract(): assert rows['hip_shoulder_separation_at_foot_down']['value'] == 30 assert rows['hip_shoulder_separation_at_contact']['value'] == 10 assert rows['stride_relative_length']['value'] == pytest.approx(22.361) - assert rows['stride_relative_length']['reasons'] == ['event_timing_uncertain', 'scale_is_model_estimated'] + assert rows['stride_relative_length']['reasons'] == ['event_timing_uncertain', 'scale_is_model_estimated', 'model_accuracy_unvalidated'] assert all(m['status'] == 'limited' and m['confidence'] is None and m['benchmark'] is None - for m in data['measurements']) + for m in data['measurements'] if m['value'] is not None) assert data['events']['contact'] == {'video_time_s': .22, 'capture_time_s': .055, - 'source': 'manual_review', 'status': 'limited', 'reasons': ['event_timing_uncertain']} + 'source': 'manual_review', 'status': 'limited', 'source_frame_index': 6, 'reasons': ['event_timing_uncertain']} assert data['athlete'] == {**PLAYER, 'batting_hand': 'right', 'lead_foot': 'left'} assert data['swing_id'] == LINEAGE['analysis_id'] + ':swing_1' # Point-only and interval-only scope fields must be absent, including nulls. @@ -124,7 +125,7 @@ def test_unavailable_dependencies_do_not_invent_or_remove_other_metrics(mode): corrected['valid'][4, MHR[name]] = False data = payload(opts, corrected, physical=mode != 'unknown_clock') rows = values(data) - assert len(rows) == 3 + assert len(rows) == 9 if mode in ('no_contact', 'dry_swing'): reason = 'contact_not_applicable' if mode == 'dry_swing' else 'contact_not_verified' assert data['events']['contact']['reasons'] == [reason] @@ -135,7 +136,8 @@ def test_unavailable_dependencies_do_not_invent_or_remove_other_metrics(mode): assert rows['hip_shoulder_separation_at_contact']['value'] == 10 if mode == 'unknown_clock': assert all(e['capture_time_s'] is None for e in data['events'].values()) - assert all(m['value'] is not None for m in rows.values()) + assert all(m['value'] is not None for k, m in rows.items() if k != 'shoulder_rotation_after_contact') + assert rows['shoulder_rotation_after_contact']['reasons'] == ['required_event_unavailable', 'capture_time_unknown'] if mode in ('unknown_up', 'moving_camera'): assert all(m['value'] is None for m in rows.values()) if mode == 'missing_shoulder': @@ -221,6 +223,10 @@ def test_export_download_revisions_and_integrity_match_motion(tmp_path, video, m assert rows[key]['value'] == pytest.approx(signed, abs=.001) artifact = manifest.artifacts['coach_payload'] assert artifact.url == url+'/coach-payload' + # Hash and size describe the exact HTTP body, including its original whitespace. + assert response.content == (parent/'coach-payload.json').read_bytes() + assert len(response.content) == artifact.size_bytes + assert hashlib.sha256(response.content).hexdigest() == artifact.sha256 assert client.get(url+'/artifacts/coach_payload', headers=AUTH).json() == data if model == 'gvhmr': assert rows['hip_shoulder_separation_at_contact']['uses_interpolated_input'] events = json.loads((parent/'events.json').read_text())['events'] @@ -304,7 +310,8 @@ def test_estimated_up_is_used_only_when_accepted_for_measurements(tmp_path, vide job, manifest = stored(fake_service(settings(tmp_path)), video, opts, up_reference=up) data = json.loads((job/'coach-payload.json').read_text()) assert validate_payload(data)[1] == {} - assert all((m['value'] is not None) == reliable for m in data['measurements']) + assert all((m['value'] is not None) == reliable for m in data['measurements'] + if m['metric_id'] != 'shoulder_rotation_after_contact') assert manifest.pipeline['inputs']['up_vector'] is None assert manifest.pipeline['calculation_inputs']['up_vector'] == ([0, -1, 0] if reliable else None)