ram-lexsi commited on
Commit
cabe736
·
verified ·
1 Parent(s): f59ccc0

List order: fewest submitted reviews first, then higher mean overall

Browse files
Files changed (2) hide show
  1. app.py +25 -2
  2. static/index.html +1 -1
app.py CHANGED
@@ -355,13 +355,36 @@ def my_subs(request: Request):
355
  return j, u, st_all, [s for s in submissions() if visible(u, j, s, st_all.get(s["id"], {}))]
356
 
357
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  @app.get("/api/submissions")
359
  def list_submissions(request: Request):
 
 
360
  j, u, st_all, subs = my_subs(request)
 
 
361
  out = []
362
- for s in subs:
363
  st = st_all.get(s["id"], {})
364
- out.append({**s, "status": st.get(j, "not_started"), "lights": lights(u, j, s, st)})
365
  return out
366
 
367
 
 
355
  return j, u, st_all, [s for s in submissions() if visible(u, j, s, st_all.get(s["id"], {}))]
356
 
357
 
358
+ def review_stats():
359
+ """{submission id: (number of submitted reviews, mean overall of those)} from the review files on disk."""
360
+ acc = {}
361
+ for f in (DATA / "reviews").glob("*/*.json"):
362
+ try:
363
+ r = json.loads(f.read_text())
364
+ except Exception:
365
+ continue
366
+ if r.get("status") != "submitted":
367
+ continue
368
+ a = acc.setdefault(f.stem, [0, []])
369
+ a[0] += 1
370
+ try:
371
+ a[1].append(float(r.get("answers", {}).get("overall")))
372
+ except (TypeError, ValueError):
373
+ pass
374
+ return {k: (n, sum(v) / len(v) if v else 0.0) for k, (n, v) in acc.items()}
375
+
376
+
377
  @app.get("/api/submissions")
378
  def list_submissions(request: Request):
379
+ """Ordered for judges: fewest submitted reviews first, then higher mean overall first. Only the order is sent,
380
+ never the scores. The page keeps the track grouping."""
381
  j, u, st_all, subs = my_subs(request)
382
+ stats = review_stats()
383
+ key = lambda s: (stats.get(s["id"], (0, 0.0))[0], -stats.get(s["id"], (0, 0.0))[1], str(s.get("number", "")))
384
  out = []
385
+ for i, s in enumerate(sorted(subs, key=key)):
386
  st = st_all.get(s["id"], {})
387
+ out.append({**s, "status": st.get(j, "not_started"), "lights": lights(u, j, s, st), "order": i})
388
  return out
389
 
390
 
static/index.html CHANGED
@@ -251,7 +251,7 @@ async function boot() {
251
 
252
  async function loadSubs() {
253
  const TO = {t1: 1, t2: 2, t3: 3};
254
- SUBS = ((await api('/api/submissions')).body || []).sort((a, b) => (TO[a.track] || 9) - (TO[b.track] || 9) || String(a.number).localeCompare(String(b.number)));
255
  const done = SUBS.filter(s => s.status === 'submitted' || s.status === 'ended_checklist').length;
256
  $('#count').textContent = `${done} of ${SUBS.length} reviewed`;
257
  $('#prog').style.width = SUBS.length ? (100 * done / SUBS.length) + '%' : 0;
 
251
 
252
  async function loadSubs() {
253
  const TO = {t1: 1, t2: 2, t3: 3};
254
+ SUBS = ((await api('/api/submissions')).body || []).sort((a, b) => (TO[a.track] || 9) - (TO[b.track] || 9) || (a.order ?? 0) - (b.order ?? 0) || String(a.number).localeCompare(String(b.number)));
255
  const done = SUBS.filter(s => s.status === 'submitted' || s.status === 'ended_checklist').length;
256
  $('#count').textContent = `${done} of ${SUBS.length} reviewed`;
257
  $('#prog').style.width = SUBS.length ? (100 * done / SUBS.length) + '%' : 0;