Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| RolePlaySectionAverage | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models; |
| 4 | |
| 5 | /** |
| 6 | * Pre-computed per-section score averages used by the roleplay dashboard |
| 7 | * radar chart ("Section Balance"). One document per |
| 8 | * (scope, scope_id, call_type) tuple, refreshed by the |
| 9 | * `roleplay:recompute-section-averages` scheduled command. |
| 10 | * |
| 11 | * scope: |
| 12 | * - 'company' → scope_id is the company_id the average belongs to |
| 13 | * - 'global' → scope_id is null, covers every user with progression data |
| 14 | * |
| 15 | * sections is a list of { name: string, score: float } entries using a |
| 16 | * user-fair mean: each user's `UserRolePlayProgression.current_averages` |
| 17 | * contributes a single per-section value regardless of session count. |
| 18 | * |
| 19 | * @property string $scope 'company' or 'global' |
| 20 | * @property string|null $scope_id Company ID for 'company', null for 'global' |
| 21 | * @property string $call_type Roleplay call type (cold-call|discovery-call) |
| 22 | * @property array<int, array{name: string, score: float}> $sections |
| 23 | * @property int $user_count Users aggregated into this snapshot |
| 24 | * @property \Carbon\Carbon|null $computed_at When this snapshot was last refreshed |
| 25 | */ |
| 26 | class RolePlaySectionAverage extends Moloquent |
| 27 | { |
| 28 | public const SCOPE_COMPANY = 'company'; |
| 29 | |
| 30 | public const SCOPE_GLOBAL = 'global'; |
| 31 | |
| 32 | protected $table = 'role_play_section_averages'; |
| 33 | |
| 34 | protected $fillable = [ |
| 35 | 'scope', |
| 36 | 'scope_id', |
| 37 | 'call_type', |
| 38 | 'sections', |
| 39 | 'user_count', |
| 40 | 'computed_at', |
| 41 | 'created_at', |
| 42 | 'updated_at', |
| 43 | ]; |
| 44 | |
| 45 | protected $casts = [ |
| 46 | 'sections' => 'array', |
| 47 | 'user_count' => 'integer', |
| 48 | 'computed_at' => 'datetime', |
| 49 | ]; |
| 50 | } |