LCOV - code coverage report
Current view: top level - schemas/domain - series.clj Coverage Total Hit
Test: lcov.info Lines: 87.2 % 47 41
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.domain.series
       2              :   (:require
       3              :    [malli.core :as m]
       4              :    [malli.error :as me]))
       5              : 
       6              : 
       7            4 : (def SeriesRecordSchema
       8           28 :   [:map {:swagger/title       "SeriesRecord"
       9              :          :swagger/description "Complete series record from database"}
      10           20 :    [:uuid [:ref :types/UuidString]]
      11            8 :    [:context-type
      12           28 :     [:string {:description "Context type"
      13              :               :example     "group"}]]
      14           20 :    [:group-id {:optional true}
      15           20 :     [:maybe [:ref :types/UuidString]]]
      16           20 :    [:bracket-match-id {:optional true}
      17           20 :     [:maybe [:ref :types/UuidString]]]
      18           20 :    [:ruleset-id {:optional true}
      19           20 :     [:maybe [:ref :types/UuidString]]]
      20            8 :    [:match-format
      21           28 :     [:string {:description "Match format"
      22              :               :example     "aggregate"}]]
      23           12 :    [:best-of :int]
      24           20 :    [:wins-required {:optional true}
      25           12 :     [:maybe :int]]
      26           12 :    [:match-count :int]
      27            8 :    [:state
      28           28 :     [:string {:description "Series state"
      29              :               :example     "scheduled"}]]
      30           20 :    [:winner-participant-id {:optional true}
      31           20 :     [:maybe [:ref :types/UuidString]]]
      32           24 :    [:extra {:optional true}
      33              :     :any]
      34           20 :    [:source [:ref :matchscore/source]]])
      35              : 
      36              : 
      37            4 : (defrecord
      38              :   SeriesRecord
      39              :   [uuid
      40              :    context-type
      41              :    group-id
      42              :    bracket-match-id
      43              :    ruleset-id
      44              :    match-format
      45              :    best-of
      46              :    wins-required
      47              :    match-count
      48              :    state
      49              :    winner-participant-id
      50              :    extra
      51              :    source])
      52              : 
      53              : 
      54            4 : (defn make-series-record
      55              :  "Creates a Series record with validation.
      56              :    Note: This validation uses the default registry. Ensure schemas.registry/init-registry!
      57              :    has been called before using this function."
      58              :  {:malli/schema [:=> [:cat SeriesRecordSchema] SeriesRecordSchema]}
      59              :  [{:keys [uuid
      60              :           context-type
      61              :           group-id
      62              :           bracket-match-id
      63              :           ruleset-id
      64              :           match-format
      65              :           best-of
      66              :           wins-required
      67              :           match-count
      68              :           state
      69              :           winner-participant-id
      70              :           extra
      71              :           source]
      72              :    :as   series-data}]
      73           10 :  (if (m/validate SeriesRecordSchema series-data)
      74            4 :    (map->SeriesRecord
      75           30 :     {:uuid             uuid
      76            2 :      :context-type     context-type
      77            2 :      :group-id         group-id
      78            2 :      :bracket-match-id bracket-match-id
      79            2 :      :ruleset-id       ruleset-id
      80            2 :      :match-format     match-format
      81            2 :      :best-of          best-of
      82            2 :      :wins-required    wins-required
      83            2 :      :match-count      match-count
      84            2 :      :state            state
      85            2 :      :winner-participant-id winner-participant-id
      86            2 :      :extra            extra
      87            2 :      :source           source})
      88            0 :    (throw
      89            0 :     (ex-info
      90              :      "Invalid series data"
      91            0 :      {:type   :internal-validation-error
      92            0 :       :schema SeriesRecordSchema
      93            0 :       :data   series-data
      94            0 :       :humanized-errors (me/humanize (m/explain SeriesRecordSchema series-data))}))))
        

Generated by: LCOV version 2.0-1