LCOV - code coverage report
Current view: top level - matchscore/domain/psa - query.clj Coverage Total Hit
Test: lcov.info Lines: 86.1 % 36 31
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1            4 : (ns matchscore.domain.psa.query
       2              :   (:require
       3              :    [matchscore.domain.player-follow.query :as follow-query]
       4              :    [matchscore.domain.psa.repository.postgres :as psa-postgres-repo]))
       5              : 
       6              : 
       7            4 : (defn get-seasons
       8              :  [repo]
       9            3 :  (psa-postgres-repo/find-seasons repo))
      10              : 
      11              : 
      12            4 : (defn get-tournaments
      13              :  "With `follow-repo` and `user-id`, each tournament lists the user's followed
      14              :   players found in its imported draw (:followed-players)."
      15            0 :  ([repo season] (get-tournaments repo season nil nil))
      16              :  ([repo season follow-repo user-id]
      17           23 :   (let [season (or season (first (psa-postgres-repo/find-seasons repo)))]
      18            6 :     (if season
      19            9 :       (follow-query/with-followed-players
      20            3 :        follow-repo
      21              :        "psa"
      22            3 :        user-id
      23           12 :        (psa-postgres-repo/find-tournaments repo season))
      24            0 :       []))))
      25              : 
      26              : 
      27            4 : (defn get-tournament
      28            0 :  ([repo psa-id] (get-tournament repo psa-id nil nil))
      29              :  ([repo psa-id follow-repo user-id]
      30           20 :   (when-let [tournament (psa-postgres-repo/find-tournament repo psa-id)]
      31           18 :     (first (follow-query/with-followed-players follow-repo "psa" user-id [tournament])))))
      32              : 
      33              : 
      34            4 : (defn get-tournament-videos
      35              :  [repo psa-id]
      36            4 :  (psa-postgres-repo/find-tournament-videos repo psa-id))
      37              : 
      38              : 
      39            4 : (defn get-ranking
      40            0 :  ([repo list-name snapshot-date] (get-ranking repo list-name snapshot-date nil nil))
      41              :  ([repo list-name snapshot-date follow-repo user-id]
      42           10 :   (let [snapshot-date (or
      43            2 :                        snapshot-date
      44            6 :                        (psa-postgres-repo/find-latest-ranking-snapshot-date repo list-name))
      45           10 :         followed?     (follow-query/followed?-fn follow-repo "psa" user-id)]
      46           10 :     {:list          list-name
      47            2 :      :snapshot-date snapshot-date
      48            4 :      :entries       (if snapshot-date
      49            4 :                       (mapv
      50            2 :                        (fn [entry]
      51            6 :                         (assoc-in entry
      52            6 :                          [:player :followed]
      53           16 :                          (followed? (get-in entry [:player :psa-id]))))
      54           10 :                        (psa-postgres-repo/find-ranking-entries repo list-name snapshot-date))
      55            0 :                       [])})))
      56              : 
      57              : 
      58            4 : (defn get-followed-players
      59              :  "Players the user follows, newest follow first; empty for guests."
      60              :  [repo user-id]
      61            7 :  (if user-id (psa-postgres-repo/find-followed-players repo user-id) []))
        

Generated by: LCOV version 2.0-1