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

            Line data    Source code
       1            4 : (ns matchscore.domain.country-exclusion
       2              :   "Countries whose players and tournaments are never shown, on any imported source
       3              :   (PSA, ESF). Russia and Belarus; PSA lists their players as AIN
       4              :   (Individual Neutral Athletes) and ESF as AIN or RSF (Russian Squash Federation).
       5              : 
       6              :   The scrapers skip the same countries on import (scrapers/psa/exclusions.py);
       7              :   keep the two lists in sync."
       8              :   (:require
       9              :    [clojure.string :as str]))
      10              : 
      11              : 
      12           24 : (def codes "Excluded country codes, upper case." ["RUS" "BLR" "AIN" "RSF"])
      13              : 
      14              : 
      15           16 : (def ^:private code-set (set codes))
      16              : 
      17              : 
      18            4 : (defn excluded?
      19              :  "True when `country-code` (any case, surrounding spaces ignored) is excluded."
      20              :  [country-code]
      21            2 :  (contains?
      22            1 :   code-set
      23           25 :   (some->
      24            1 :     country-code
      25            1 :     str
      26            1 :     str/trim
      27            1 :     str/upper-case)))
      28              : 
      29              : 
      30            4 : (defn allowed-sql
      31              :  "SQL condition: the country code in the column expression `col` is not excluded.
      32              :   A missing country is allowed."
      33              :  [col]
      34           20 :  (str
      35              :   "upper(trim(coalesce("
      36            4 :   col
      37              :   ", ''))) NOT IN ("
      38           48 :   (str/join ", " (map #(str "'" % "'") codes))
      39              :   ")"))
      40              : 
      41              : 
      42            4 : (defn allowed-honey
      43              :  "HoneySQL condition: the country code in column `col` is not excluded."
      44              :  [col]
      45           44 :  [:not-in [:coalesce [:upper [:trim col]] ""] codes])
        

Generated by: LCOV version 2.0-1