Skip to content

Commit

Permalink
Display my benchmarks first
Browse files Browse the repository at this point in the history
  • Loading branch information
VukW committed Aug 10, 2024
1 parent c225a5e commit ad0451f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cli/medperf/web_ui/benchmarks/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@
@router.get("/ui", response_class=HTMLResponse)
def benchmarks_ui(request: Request, local_only: bool = False, mine_only: bool = False):
filters = {}
my_user_id = get_medperf_user_data()["id"]
if mine_only:
filters["owner"] = get_medperf_user_data()["id"]
filters["owner"] = my_user_id

benchmarks = Benchmark.all(
local_only=local_only,
filters=filters,
)

benchmarks = sorted(benchmarks, key=lambda x: x.created_at, reverse=True)
# sort by (mine recent) (mine oldish), (other recent), (other oldish)
mine_benchmarks = [d for d in benchmarks if d.owner == my_user_id]
other_benchmarks = [d for d in benchmarks if d.owner != my_user_id]
benchmarks = mine_benchmarks + other_benchmarks
return templates.TemplateResponse("benchmarks.html", {"request": request, "benchmarks": benchmarks})


Expand Down

0 comments on commit ad0451f

Please sign in to comment.