sessionId = $session; } #[Computed] public function band(): object { return DB::table('session_summaries') ->where('id', $this->sessionId) ->where(function ($q) { $q->where('visibility', 'public'); if (auth()->user() !== null) { $q->orWhere(function ($own) { $own->where('visibility', 'private') ->where('user_id', auth()->id()); }); } }) ->firstOrFail(); } #[Computed] public function runs() { $band = $this->band; return BenchmarkRun::where('suite', 'scenariobench') ->where('model_id', $band->model_id) ->where('model_quant', $band->model_quant) ->where('gpu', $band->gpu) ->where('gpu_count', $band->gpu_count) ->where('user_id', $band->user_id) ->where('visibility', $band->visibility) ->where('engine', $band->engine) ->where(function ($q) use ($band) { $q->whereNull('config_id') ->orWhere('config_id', $this->configIdFromName($band->config_name)); }) ->where(function ($q) use ($band) { if ($band->label !== null && $band->label !== '') { $q->where('label', $band->label); } else { $q->where(function ($inner) { $inner->whereNull('label')->orWhere('label', ''); }); } }) ->orderBy('ran_at') ->get(); } private function configIdFromName(?string $name): ?int { if ($name === null) { return null; } return DB::table('server_configs')->where('name', $name)->value('id'); } #[Computed] public function results() { $runIds = $this->runs->pluck('id'); $column = in_array($this->sortBy, self::SORTABLE, true) ? $this->sortBy : 'scenario'; $direction = $this->sortDirection === 'asc' ? 'asc' : 'desc'; $query = DB::table('scenario_runs') ->whereIn('benchmark_run_id', $runIds); if ($column === 'gen_tps') { $query->orderByRaw('gen_tokens / nullif(wall, 0) '.$direction); } else { $query->orderBy($column, $direction); } return $query->orderBy('id')->get(); } }; ?>