LCOV - code coverage report
Current view: top level - matchscore/application/scoreboard - groups.clj Coverage Total Hit
Test: lcov.info Lines: 100.0 % 16 16
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns matchscore.application.scoreboard.groups
       2              :   "Builds scoreboard entries for a group draw: one entry per group with
       3              :    ordered placements derived from the existing ranking logic."
       4              :   (:require
       5              :    [matchscore.application.advancement.common :as adv-common]))
       6              : 
       7              : 
       8            4 : (defn- group-placements
       9              :   [{:keys [group participants ranked-participants]}]
      10           10 :   (let [ranked-pids    (mapv str ranked-participants)
      11              :         ;; Cap at the number of real participants, not the number of slots: a
      12              :         ;; 3-player group in a 4-slot group has only 3 placements — the empty
      13              :         ;; slot is not a fillable position. Real players whose rank is not yet
      14              :         ;; decided are still emitted (as nil) up to the real count.
      15           10 :         real-count     (count (filter :participant-id participants))
      16           12 :         unranked-cnt   (max 0 (- real-count (count ranked-pids)))
      17           14 :         slots-with-pid (concat ranked-pids (repeat unranked-cnt nil))]
      18           10 :     {:type    "group"
      19            6 :      :name    (:name group)
      20            4 :      :results (mapv
      21            2 :                (fn [idx pid]
      22           10 :                 {:place (inc idx)
      23            2 :                  :participant-id pid})
      24            4 :                (range)
      25            2 :                slots-with-pid)}))
      26              : 
      27              : 
      28            4 : (defn compute-group-placements
      29              :  "Returns a vector of group-result entries for the given groups-draw:
      30              : 
      31              :      [{:type \"group\" :name \"Group A\"
      32              :        :results [{:place 1 :participant-id <pid-or-nil>} ...]} ...]
      33              : 
      34              :    Each :participant-id is either a UUID string (resolved) or nil
      35              :    (unfilled slot or undetermined ranking)."
      36              :  [repos draw-uuid]
      37            7 :  (mapv group-placements (adv-common/load-ranked-groups repos draw-uuid)))
        

Generated by: LCOV version 2.0-1