LCOV - code coverage report
Current view: top level - schemas/domain - user_rankedin.clj Coverage Total Hit
Test: lcov.info Lines: 87.5 % 48 42
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns schemas.domain.user-rankedin
       2              :   (:require
       3              :    [malli.core :as m]
       4              :    [malli.error :as me]))
       5              : 
       6              : 
       7            4 : (def UserRankedinRecordSchema
       8           28 :   [:map {:swagger/title       "UserRankedinRecord"
       9              :          :swagger/description "A RankedIn user account linked from an external RankedIn service"}
      10           20 :    [:uuid [:ref :types/UuidString]]
      11            8 :    [:rankedin-id
      12           28 :     [:int {:description "External RankedIn numeric user ID"
      13              :            :example     12345}]]
      14           28 :    [:source {:optional true
      15              :              :default  "rankedin"}
      16           12 :     [:ref :matchscore/source]]
      17            8 :    [:first-name
      18            8 :     [:maybe
      19           28 :      [:string {:description "User's first name"
      20              :                :example     "John"}]]]
      21            8 :    [:last-name
      22            8 :     [:maybe
      23           28 :      [:string {:description "User's last name"
      24              :                :example     "Doe"}]]]
      25            8 :    [:username
      26            8 :     [:maybe
      27           28 :      [:string {:description "RankedIn username"
      28              :                :example     "johndoe"}]]]
      29            8 :    [:photo-url
      30            8 :     [:maybe
      31           28 :      [:string {:description "URL to user's profile photo"
      32              :                :example     "https://example.com/photo.jpg"}]]]
      33           20 :    [:profile-url {:optional true}
      34           12 :     [:maybe :string]]
      35            8 :    [:country-code
      36            8 :     [:maybe
      37           28 :      [:string {:description "ISO country code"
      38              :                :example     "US"}]]]
      39           20 :    [:rating {:optional true}
      40            8 :     [:maybe
      41           28 :      [:int {:description "RankedIn user rating"
      42              :             :example     1500}]]]])
      43              : 
      44              : 
      45            4 : (defrecord
      46              :   UserRankedinRecord
      47              :   [uuid rankedin-id source first-name last-name username photo-url profile-url country-code rating])
      48              : 
      49              : 
      50            4 : (defn make-user-rankedin-record
      51              :  "Creates a UserRankedin record with validation."
      52              :  {:malli/schema [:=> [:cat UserRankedinRecordSchema] UserRankedinRecordSchema]}
      53              :  [{:keys
      54              :    [uuid rankedin-id source first-name last-name username photo-url profile-url country-code rating]
      55              :    :as user-data}]
      56           10 :  (if (m/validate UserRankedinRecordSchema user-data)
      57            4 :    (map->UserRankedinRecord
      58           24 :     {:uuid         uuid
      59            2 :      :rankedin-id  rankedin-id
      60           10 :      :source       (or source "rankedin")
      61            2 :      :first-name   first-name
      62            2 :      :last-name    last-name
      63            2 :      :username     username
      64            2 :      :photo-url    photo-url
      65            2 :      :profile-url  profile-url
      66            2 :      :country-code country-code
      67            2 :      :rating       rating})
      68            0 :    (throw
      69            0 :     (ex-info
      70              :      "Invalid user rankedin data"
      71            0 :      {:type   :internal-validation-error
      72            0 :       :schema UserRankedinRecordSchema
      73            0 :       :data   user-data
      74            0 :       :humanized-errors (me/humanize (m/explain UserRankedinRecordSchema user-data))}))))
        

Generated by: LCOV version 2.0-1