LCOV - code coverage report
Current view: top level - matchscore/graphql - resolvers.clj Coverage Total Hit
Test: lcov.info Lines: 92.9 % 1645 1529
Test Date: 2026-11-23 18:11:10 Functions: - 0 0

            Line data    Source code
       1              : ;!zprint {:format :off}
       2            4 : (ns matchscore.graphql.resolvers
       3              :   (:require
       4              :    [cats.core :as c]
       5              :    [cats.monad.either :as either]
       6              :    [cheshire.core :as json]
       7              :    [clojure.string :as str]
       8              :    [com.walmartlabs.lacinia.executor :as executor]
       9              :    [com.walmartlabs.lacinia.resolve :as resolve]
      10              :    [superlifter.api :as s]
      11              :    [superlifter.lacinia :as sl]
      12              :    [taoensso.telemere :as t]
      13              : 
      14              :    [matchscore.access.resource :as access-resource]
      15              :    [matchscore.application.advancement.common :as advancement-common]
      16              :    [matchscore.application.scoreboard.get :as app-scoreboard]
      17              :    [matchscore.application.telegram-access :as app-telegram-access]
      18              :    [matchscore.db.postgres.template-automation :as automation-db]
      19              :    [matchscore.db.postgres.user-updates :as user-updates-db]
      20              :    [matchscore.dev.notification-samples :as dev-samples]
      21              :    [matchscore.domain.advancement-rule.query :as advancement-rule-query]
      22              :    [matchscore.domain.advancement.query :as advancement-query]
      23              :    [matchscore.domain.bracket-match-slot.query :as bracket-match-slot-query]
      24              :    [matchscore.domain.bracket-match.query :as bracket-match-query]
      25              :    [matchscore.domain.bracket-round.query :as bracket-round-query]
      26              :    [matchscore.domain.bracket.query :as bracket-query]
      27              :    [matchscore.domain.class-participant.entity :as class-participant-entity]
      28              :    [matchscore.domain.class-participant.query :as class-participant-query]
      29              :    [matchscore.domain.class-template-participant.query :as class-template-participant-query]
      30              :    [matchscore.domain.class-template.query :as class-template-query]
      31              :    [matchscore.domain.class.query :as class-query]
      32              :    [matchscore.domain.club.query :as club-query]
      33              :    [matchscore.domain.draw.query :as draw-query]
      34              :    [matchscore.domain.event-participant.query :as event-participant-query]
      35              :    [matchscore.domain.event.query :as event-query]
      36              :    [matchscore.domain.event.source-link :as event-source-link]
      37              :    [matchscore.domain.esf.repository.postgres :as esf-repo]
      38              :    [matchscore.domain.fsu.query :as fsu-query]
      39              :    [matchscore.domain.player-follow.query :as follow-query]
      40              :    [matchscore.domain.player-follow.repository.postgres :as player-follow-repo]
      41              :    [matchscore.domain.psa.query :as psa-query]
      42              :    [matchscore.domain.group-participant.query :as group-participant-query]
      43              :    [matchscore.domain.group.query :as group-query]
      44              :    [matchscore.domain.match-result.query :as match-result-query]
      45              :    [matchscore.domain.match-segment.query :as match-segment-query]
      46              :    [matchscore.domain.match.query :as match-query]
      47              :    [matchscore.domain.participant.query :as participant-query]
      48              :    [matchscore.domain.resource.query :as resource-query]
      49              :    [matchscore.domain.series.query :as series-query]
      50              :    [matchscore.domain.source-sync.query :as source-sync-query]
      51              :    [matchscore.domain.stage.query :as stage-query]
      52              :    [matchscore.domain.team.query :as team-query]
      53              :    [matchscore.domain.telegram-chat-message.repository.postgres :as telegram-chat-message-repo]
      54              :    [matchscore.domain.telegram-link.query :as telegram-link-query]
      55              :    [matchscore.domain.template-participant.query :as template-participant-query]
      56              :    [matchscore.domain.template.query :as template-query]
      57              :    [matchscore.domain.tournament-subscription.command :as subscription-command]
      58              :    [matchscore.domain.tournament-subscription.query :as subscription-query]
      59              :    [matchscore.domain.tournament-subscription.repository :as subscription-repo]
      60              :    [matchscore.domain.tournament-subscription.repository.postgres :as subscription-postgres]
      61              :    [matchscore.domain.user-rankedin.query :as user-rankedin-query]
      62              :    [matchscore.domain.user.query :as user-query]
      63              :    [matchscore.domain.user.repository.redis :as user-redis-repo]
      64              :    [matchscore.media.service :as media]
      65              :    [matchscore.search.events :as search-events]
      66              :    [matchscore.telegram.draws-revision :as draws-revision]
      67              :    [matchscore.telegram.match-notifications :as match-notifications]
      68              :    [matchscore.utils.ring.case-transformers :refer [domain->graphql]]
      69              :    [matchscore.utils.uuid :as utils.uuid])
      70              :   (:import
      71              :    (java.time Instant OffsetDateTime)))
      72              : 
      73              : 
      74              : ;!zprint {:format :on}
      75              : 
      76              : 
      77            4 : (defn- either->resolve
      78              :   "Converts an Either to a Lacinia resolver result.
      79              :    Left becomes an error, Right is returned as-is."
      80              :   [either-val]
      81           16 :   (if (either/right? either-val)
      82           12 :     (c/extract either-val)
      83           30 :     (resolve/resolve-as nil {:message (:message (c/extract either-val))})))
      84              : 
      85              : 
      86            4 : (defn- parse-pagination
      87              :   "Converts GraphQL pagination args to domain pagination map.
      88              :    Returns Either<Error, PaginationMap>."
      89              :   [args]
      90           35 :   (let [{:keys [limit cursor offset sortBy sortDir]} (or (:pagination args) {})]
      91           41 :     (if (and (some? cursor) (some? offset))
      92           15 :       (either/left {:message "Cannot use both cursor and offset. Provide one or the other."})
      93            8 :       (either/right
      94           63 :        (cond-> {}
      95           20 :          limit   (assoc :limit limit)
      96           16 :          cursor  (assoc :cursor cursor)
      97            8 :          offset  (assoc :offset offset)
      98           10 :          sortBy  (assoc :sort-by
      99            4 :                   (->
     100            2 :                     sortBy
     101            2 :                     str
     102           10 :                     (str/replace #"([a-z0-9])([A-Z])" "$1-$2")
     103            8 :                     (str/replace #"_" "-")
     104            2 :                     str/lower-case
     105            2 :                     keyword))
     106           12 :          sortDir (assoc :sort-dir (keyword sortDir)))))))
     107              : 
     108              : 
     109           32 : (defn- group-by-str [f coll] (group-by (comp str f) coll))
     110              : 
     111              : 
     112           28 : (defn- get-str-key [m k default] (get m (str k) default))
     113              : 
     114              : 
     115           31 : (defn- guest-context? [ctx] (nil? (get-in ctx [:auth-headers :user/uuid])))
     116              : 
     117              : 
     118            4 : (defn- private-field-resolver
     119              :   [field]
     120            4 :   (fn [ctx _args val]
     121           25 :    (when-not (guest-context? ctx) (get val field))))
     122              : 
     123              : 
     124            4 : (defn- private-list-field-resolver
     125              :   [field]
     126            4 :   (fn [ctx _args val]
     127            0 :    (if (guest-context? ctx) [] (vec (or (get val field) [])))))
     128              : 
     129              : 
     130            4 : (defn account-resolver
     131              :  [ctx _args _val]
     132           14 :  (let [user-repo  (get-in ctx [:repos :user-postgres-repo])
     133           12 :        user-redis (get-in ctx [:repos :user-redis-repo])
     134           12 :        tg-uuid    (get-in ctx [:auth-headers :user/uuid])
     135           12 :        tg-id      (get-in ctx [:auth-headers :telegram/id])
     136            8 :        user       (user-query/get-user user-repo tg-uuid)]
     137              :    ;; Self-heal a stale telegram-id→uuid cache (e.g. after a DB reset while Redis
     138              :    ;; persisted): the resolved uuid has no user row. Drop the mapping so the next
     139              :    ;; open re-resolves from Postgres and auto-provisions a fresh account.
     140           31 :    (when (and tg-uuid (nil? user) tg-id user-redis)
     141            0 :      (t/log!
     142              :       :warn
     143            0 :       {:message     "Stale telegram→uuid cache; invalidating mapping"
     144            0 :        :telegram-id tg-id
     145            0 :        :stale-uuid  tg-uuid})
     146            0 :      (user-redis-repo/invalidate-tg-uuid! user-redis tg-id))
     147            6 :    (domain->graphql user)))
     148              : 
     149              : 
     150            4 : (defn user-telegram-match-notifications-enabled-resolver
     151              :  [_ctx _args settings]
     152            3 :  (match-notifications/user-enabled? settings))
     153              : 
     154              : 
     155            4 : (defn user-name-localized-resolver
     156              :  [_ctx _args user]
     157            0 :  (->>
     158            0 :    (:nameLocalized user)
     159            0 :    (map
     160            0 :     (fn [[language value]]
     161            0 :      {:language (name language)
     162            0 :       :value    value}))
     163            0 :    (sort-by :language)
     164            0 :    vec))
     165              : 
     166              : 
     167            4 : (defn private-name-confirmed-at-resolver
     168              :  [ctx _args user]
     169            0 :  (when-not (guest-context? ctx)
     170            0 :    (some->
     171            0 :      (:nameConfirmedAt user)
     172            0 :      str)))
     173              : 
     174              : 
     175            4 : (defn account-name-locks-resolver
     176              :  "Resolves the name locks only for the account owner."
     177              :  [ctx _args val]
     178            7 :  (let [caller-uuid (get-in ctx [:auth-headers :user/uuid])
     179            7 :        target-uuid (or (:uuid val) (:userId val))]
     180           18 :    (if (and caller-uuid (= caller-uuid target-uuid)) (vec (or (:nameLocks val) [])) [])))
     181              : 
     182              : 
     183            4 : (defn account-roles-resolver
     184              :  "Resolves global roles on the authenticated account."
     185              :  [ctx _args val]
     186           14 :  (let [caller-uuid (get-in ctx [:auth-headers :user/uuid])
     187           14 :        target-uuid (or (:uuid val) (:userId val))]
     188           35 :    (if (and caller-uuid (= caller-uuid target-uuid)) (vec (or (:roles val) [])) [])))
     189              : 
     190              : 
     191            4 : (defn user-resolver
     192              :  [ctx args _val]
     193           14 :  (let [user-repo (get-in ctx [:repos :user-postgres-repo])
     194            6 :        id        (:id args)]
     195            2 :    (->
     196            8 :      (user-query/get-user user-repo id)
     197            2 :      domain->graphql)))
     198              : 
     199              : 
     200            4 : (defn users-resolver
     201              :  [ctx _args _val]
     202            7 :  (let [user-repo       (get-in ctx [:repos :user-postgres-repo])
     203            6 :        user-redis-repo (get-in ctx [:repos :user-redis-repo])]
     204            7 :    (mapv domain->graphql (user-query/get-users user-repo user-redis-repo))))
     205              : 
     206              : 
     207            4 : (defn reference-data-resolver
     208              :  [ctx _args _val]
     209            7 :  (let [{:keys [sports activity-types]} (get-in ctx [:repos :reference-data])]
     210            2 :    (domain->graphql
     211            8 :     {:sports         (or sports [])
     212            5 :      :activity-types (or activity-types [])})))
     213              : 
     214              : 
     215            4 : (defn search-users-resolver
     216              :  [ctx args _val]
     217            4 :  (either->resolve
     218           20 :   (c/mlet [pagination (parse-pagination args)]
     219            7 :     (let [user-repo (get-in ctx [:repos :user-postgres-repo])
     220            8 :           filters   (or (:filter args) {})
     221            5 :           result    (user-query/search-users user-repo filters pagination)]
     222            2 :       (either/right
     223            1 :        (->
     224            1 :          result
     225            8 :          (update :items #(mapv domain->graphql %))
     226            1 :          domain->graphql))))))
     227              : 
     228              : 
     229            4 : (defn search-users-for-event-resolver
     230              :  [ctx args _val]
     231            2 :  (either->resolve
     232           10 :   (c/mlet [pagination (parse-pagination args)]
     233            7 :     (let [user-repo (get-in ctx [:repos :user-postgres-repo])
     234            3 :           event-id  (:eventId args)
     235            7 :           filters   (or (:filter args) {})
     236            6 :           result    (user-query/search-users-for-event user-repo event-id filters pagination)]
     237            2 :       (either/right
     238            1 :        (->
     239            1 :          result
     240            8 :          (update :items #(mapv domain->graphql %))
     241            1 :          domain->graphql))))))
     242              : 
     243              : 
     244            4 : (defn search-users-for-template-resolver
     245              :  [ctx args _val]
     246            2 :  (either->resolve
     247           10 :   (c/mlet [pagination (parse-pagination args)]
     248            7 :     (let [user-repo (get-in ctx [:repos :user-postgres-repo])
     249            3 :           template-id (:templateId args)
     250            7 :           filters (or (:filter args) {})
     251            6 :           result (user-query/search-users-for-template user-repo template-id filters pagination)]
     252            2 :       (either/right
     253            1 :        (->
     254            1 :          result
     255            8 :          (update :items #(mapv domain->graphql %))
     256            1 :          domain->graphql))))))
     257              : 
     258              : 
     259            4 : (defn club-resolver
     260              :  [ctx args _val]
     261            7 :  (let [club-repo (get-in ctx [:repos :club-postgres-repo])
     262            3 :        id        (:id args)]
     263            1 :    (->
     264            4 :      (club-query/get-club club-repo id)
     265            1 :      domain->graphql)))
     266              : 
     267              : 
     268            4 : (defn clubs-resolver
     269              :  [ctx _args _val]
     270            7 :  (let [club-repo       (get-in ctx [:repos :club-postgres-repo])
     271            6 :        club-redis-repo (get-in ctx [:repos :club-redis-repo])]
     272            7 :    (mapv domain->graphql (club-query/get-clubs club-repo club-redis-repo))))
     273              : 
     274              : 
     275           28 : (defn- user-id [ctx] (get-in ctx [:auth-headers :user/uuid]))
     276              : 
     277              : 
     278            4 : (defn- follow-repository
     279              :   "Follow repository from the system, or one over the same datasource as the
     280              :   imported-tour repository (tests that inject only a source repository)."
     281              :   [ctx]
     282           70 :   (or
     283           18 :    (get-in ctx [:repos :player-follow-postgres-repo])
     284              :    (some->>
     285           12 :      [:psa-postgres-repo :esf-postgres-repo :fsu-postgres-repo]
     286           33 :      (keep #(get-in ctx [:repos % :ds]))
     287            3 :      first
     288            3 :      player-follow-repo/make-repository)))
     289              : 
     290              : 
     291            4 : (defn- with-entries-followed
     292              :   "Marks each entry of a ranking/rating page :followed, keyed by `key-fn`."
     293              :   [ctx source key-fn page]
     294           20 :   (let [followed? (follow-query/followed?-fn (follow-repository ctx) source (user-id ctx))]
     295           12 :     (cond-> page
     296           10 :       (seq (:entries page))
     297           28 :       (update :entries (partial mapv #(assoc % :followed (followed? (key-fn %))))))))
     298              : 
     299              : 
     300            4 : (defn- esf-repository
     301              :   [ctx]
     302           12 :   (or
     303           18 :    (get-in ctx [:repos :esf-postgres-repo])
     304            0 :    (when-let [repo (get-in ctx [:repos :fsu-postgres-repo])]
     305            0 :      (esf-repo/make-repository (:ds repo)))))
     306              : 
     307              : 
     308              : ;; ---------------------------------------------------------------------------
     309              : ;; Tournament subscriptions, tiers and the in-app feed
     310              : 
     311              : 
     312            4 : (defn- subscription-repository
     313              :   "Subscription repository from the system, or one over the same datasource as
     314              :   another imported-tour repository (tests that inject only those)."
     315              :   [ctx]
     316           93 :   (or
     317           24 :    (get-in ctx [:repos :tournament-subscription-repo])
     318              :    (some->>
     319           24 :      [:psa-postgres-repo
     320              :       :esf-postgres-repo
     321              :       :fsu-postgres-repo
     322              :       :player-follow-postgres-repo
     323              :       :user-postgres-repo]
     324           44 :      (keep #(get-in ctx [:repos % :ds]))
     325            4 :      first
     326            4 :      subscription-postgres/make-repository)))
     327              : 
     328              : 
     329            4 : (defn- ->iso
     330              :   [t]
     331           28 :   (some->
     332            2 :     t
     333            2 :     (as-> t
     334           12 :       (cond (instance? java.sql.Timestamp t) (.toInstant ^java.sql.Timestamp t)
     335            0 :             (instance? OffsetDateTime t)     (.toInstant ^OffsetDateTime t)
     336            0 :             :else                            t))
     337            2 :     str))
     338              : 
     339              : 
     340            4 : (defn- subscription->graphql
     341              :   [row]
     342           26 :   {:id          (str (:uuid row))
     343            6 :    :source      (:source row)
     344            6 :    :target      (:target row)
     345            6 :    :targetKey   (:target-key row)
     346           14 :    :targetLabel (or (:target-label row) (:target-key row) (str/upper-case (:source row)))
     347            6 :    :matchScope  (:match-scope row)
     348           10 :    :createdAt   (->iso (:created-datetime row))})
     349              : 
     350              : 
     351            4 : (defn- tier->graphql
     352              :   [tier]
     353           16 :   {:source          (:source tier)
     354            6 :    :code            (:code tier)
     355            6 :    :label           (:label tier)
     356           14 :    :tournamentCount (or (:tournament-count tier) 0)})
     357              : 
     358              : 
     359            4 : (defn- request-language
     360              :   [ctx]
     361           13 :   (or
     362           21 :    (when-let [uid (user-id ctx)]
     363           13 :      (some->
     364            6 :        (get-in ctx [:repos :user-postgres-repo])
     365            4 :        (user-query/get-user uid)
     366            4 :        (get-in [:settings :language])))
     367              :    "en"))
     368              : 
     369              : 
     370            4 : (defn- with-tournament-tiers
     371              :   "Adds :tier and :subscription to every calendar row with one tier query and
     372              :   one subscription query for the whole list, not per tournament."
     373              :   [ctx source key-fn tournaments]
     374           12 :   (let [repo (subscription-repository ctx)]
     375           33 :     (if (or (nil? repo) (empty? tournaments))
     376            1 :       tournaments
     377            3 :       (let [tiers
     378           30 :             (subscription-query/tiers-by-tournament repo (:ds repo) source (request-language ctx))
     379           21 :             subs (when-let [uid (user-id ctx)]
     380            5 :                    (subscription-query/tournament-subscriptions repo uid source))]
     381            6 :         (mapv
     382            3 :          (fn [t]
     383           18 :           (let [k (str (key-fn t))]
     384           15 :             (assoc t
     385           23 :              :tier         (some->
     386            9 :                              (get tiers k)
     387            2 :                              tier->graphql)
     388           23 :              :subscription (some->
     389            9 :                              (get subs k)
     390            1 :                              subscription->graphql))))
     391            3 :          tournaments)))))
     392              : 
     393              : 
     394            4 : (defn tournament-tiers-resolver
     395              :  [ctx {:keys [source]} _val]
     396            4 :  (let [repo (subscription-repository ctx)
     397            3 :        lang (request-language ctx)]
     398           11 :    (if (and repo (contains? #{"psa" "esf"} source))
     399            2 :      (mapv
     400            1 :       (fn [t]
     401            6 :        {:source          source
     402            3 :         :code            (:code t)
     403           14 :         :label           (if (= "uk" lang) (or (:label-uk t) (:label-en t)) (:label-en t))
     404            7 :         :tournamentCount (or (:tournament-count t) 0)})
     405            4 :       (subscription-repo/list-tiers repo source))
     406            1 :      [])))
     407              : 
     408              : 
     409            4 : (defn my-tournament-subscriptions-resolver
     410              :  [ctx _args _val]
     411            8 :  (if-let [uid (user-id ctx)]
     412            2 :    (mapv
     413            1 :     subscription->graphql
     414            6 :     (subscription-repo/list-subscriptions (subscription-repository ctx) uid))
     415            1 :    []))
     416              : 
     417              : 
     418            8 : (def ^:private auth-required "Authentication required")
     419              : 
     420              : 
     421            4 : (defn subscribe-tournaments-resolver
     422              :  [ctx {:keys [source target targetKey matchScope]} _val]
     423           16 :  (if-let [uid (user-id ctx)]
     424            6 :    (let [result (subscription-command/subscribe!
     425           10 :                  (:ds (subscription-repository ctx))
     426            2 :                  uid
     427           12 :                  {:source      source
     428            2 :                   :target      target
     429            2 :                   :target-key  targetKey
     430            2 :                   :match-scope matchScope})]
     431            8 :      (if (either/right? result)
     432           10 :        (subscription->graphql (c/extract result))
     433           10 :        (resolve/resolve-as nil {:message (:message (c/extract result))})))
     434            6 :    (resolve/resolve-as nil {:message auth-required})))
     435              : 
     436              : 
     437            4 : (defn unsubscribe-tournaments-resolver
     438              :  [ctx {:keys [id]} _val]
     439            8 :  (if-let [uid (user-id ctx)]
     440            7 :    (if (utils.uuid/uuid-string? (str id))
     441            9 :      (subscription-command/unsubscribe! (:ds (subscription-repository ctx)) uid id)
     442              :      false)
     443            6 :    (resolve/resolve-as nil {:message auth-required})))
     444              : 
     445              : 
     446           14 : (defn- updates-datasource [ctx] (:ds (subscription-repository ctx)))
     447              : 
     448              : 
     449            4 : (defn- update->graphql
     450              :   [row]
     451            4 :   (let [payload (:payload row)]
     452           15 :     {:id            (str (:uuid row))
     453            3 :      :kind          (:kind row)
     454            3 :      :source        (:source row)
     455            7 :      :eventId       (some->
     456            3 :                       (:event-id row)
     457            0 :                       str)
     458            8 :      :tournamentKey (some->
     459            3 :                       (:tournament-key payload)
     460            1 :                       str)
     461            7 :      :payload       (json/generate-string (or payload {}))
     462            5 :      :createdAt     (->iso (:created-datetime row))
     463            5 :      :updatedAt     (->iso (:updated-datetime row))
     464            5 :      :read          (some? (:read-at row))}))
     465              : 
     466              : 
     467            4 : (defn my-updates-resolver
     468              :  [ctx {:keys [cursor limit unreadOnly]} _val]
     469           14 :  (if-let [uid (user-id ctx)]
     470            1 :    (try
     471            3 :      (let [page (user-updates-db/feed-page
     472            3 :                  (updates-datasource ctx)
     473            1 :                  uid
     474            6 :                  {:cursor         cursor
     475            1 :                   :limit          limit
     476            2 :                   :unread-only?   (boolean unreadOnly)
     477            1 :                   :retention-days (long
     478            4 :                                    (or
     479            7 :                                     (get-in ctx [:config :notifications/updates :retention-days])
     480              :                                     90))})]
     481            9 :        {:items      (mapv update->graphql (:items page))
     482            3 :         :nextCursor (:next-cursor page)})
     483            0 :      (catch IllegalArgumentException _ (resolve/resolve-as nil {:message "Invalid cursor"})))
     484            5 :    {:items      []
     485              :     :nextCursor nil}))
     486              : 
     487              : 
     488            4 : (defn unread-updates-count-resolver
     489              :  [ctx _args _val]
     490           15 :  (if-let [uid (user-id ctx)]
     491            2 :    (user-updates-db/unread-count
     492            3 :     (updates-datasource ctx)
     493            1 :     uid
     494           12 :     (long (or (get-in ctx [:config :notifications/updates :retention-days]) 90)))
     495              :    0))
     496              : 
     497              : 
     498            4 : (defn mark-updates-read-resolver
     499              :  [ctx {:keys [upTo]} _val]
     500           14 :  (if-let [uid (user-id ctx)]
     501            4 :    (let [up-to (when upTo
     502            1 :                  (try
     503            5 :                    (str (Instant/parse upTo))
     504              :                    (catch Exception _
     505            2 :                      (try
     506            6 :                        (str (.toInstant (OffsetDateTime/parse upTo)))
     507              :                        (catch Exception _ ::invalid)))))]
     508            4 :      (if (= ::invalid up-to)
     509            6 :        (resolve/resolve-as nil {:message "upTo must be an ISO-8601 time"})
     510            7 :        (user-updates-db/mark-read! (updates-datasource ctx) uid up-to)))
     511            6 :    (resolve/resolve-as nil {:message auth-required})))
     512              : 
     513              : 
     514            4 : (defn set-updates-read-resolver
     515              :  [ctx {:keys [ids read]} _val]
     516            9 :  (cond (nil? (user-id ctx)) (resolve/resolve-as nil {:message auth-required})
     517            4 :        (< 500 (count ids)) (resolve/resolve-as nil {:message "At most 500 ids at a time"})
     518           11 :        :else (user-updates-db/set-read! (updates-datasource ctx) (user-id ctx) ids (boolean read))))
     519              : 
     520              : 
     521            4 : (defn dev-test-notifications-resolver
     522              :  "LOCAL DEVELOPMENT ONLY: sample notifications for the caller (see matchscore.dev.notification-samples)."
     523              :  [ctx {:keys [action]} _val]
     524            4 :  (let [uid  (user-id ctx)
     525            8 :        opts {:config  (:config ctx)
     526            3 :              :bot     (:bot ctx)
     527            3 :              :ds      (updates-datasource ctx)
     528            1 :              :user-id uid}]
     529            8 :    (cond (not (dev-samples/enabled? (:config ctx)))
     530            6 :          (resolve/resolve-as nil {:message "Dev tools are disabled"})
     531              : 
     532            0 :          (nil? uid) (resolve/resolve-as nil {:message auth-required})
     533            0 :          (= action "feed:seed") (str "Added " (dev-samples/seed-feed! opts) " sample feed items")
     534            0 :          (= action "feed:clear")
     535            0 :          (str "Removed " (dev-samples/clear-feed! opts) " sample feed items")
     536              : 
     537            0 :          (str/starts-with? (str action) "telegram:")
     538            0 :          (let [{:keys [sent error]} (dev-samples/send-telegram-samples!
     539            0 :                                      (assoc opts :action (subs action (count "telegram:"))))]
     540            0 :            (if error
     541            0 :              (resolve/resolve-as nil {:message error})
     542            0 :              (str "Sending " sent " sample digests to your Telegram")))
     543              : 
     544            0 :          :else (resolve/resolve-as nil {:message (str "Unknown action " action)}))))
     545              : 
     546              : 
     547            4 : (defn user-notification-settings-resolver
     548              :  "The stored notification preferences; unset keys stay null (the client applies defaults).
     549              :   Settings arrive camelCased from `domain->graphql`; kebab keys are accepted too."
     550              :  [_ctx _args settings]
     551            9 :  (when-let [n (:notifications settings)]
     552            1 :    (letfn
     553           12 :      [(v [& ks] (get n (first (filter #(contains? n %) ks))))]
     554           10 :      {:telegram        (v :telegram)
     555            4 :       :inApp           (v :inApp :in-app)
     556            3 :       :results         (v :results)
     557            4 :       :followedPairings (v :followedPairings :followed-pairings)
     558            4 :       :followedResults (v :followedResults :followed-results)
     559            3 :       :video           (v :video)})))
     560              : 
     561              : 
     562            4 : (defn esf-tournaments-resolver
     563              :  [ctx args _]
     564            6 :  (mapv
     565            3 :   domain->graphql
     566            9 :   (follow-query/with-followed-players
     567            9 :    (follow-repository ctx)
     568              :    "esf"
     569            9 :    (user-id ctx)
     570           12 :    (with-tournament-tiers
     571            3 :     ctx
     572              :     "esf"
     573              :     :ts-id
     574           24 :     (esf-repo/find-tournaments (esf-repository ctx) (:year args))))))
     575              : 
     576              : 
     577            4 : (defn esf-tournament-resolver
     578              :  [ctx args _]
     579           73 :  (some->
     580           16 :    (esf-repo/find-tournament (esf-repository ctx) (:tsId args))
     581            2 :    vector
     582           14 :    (as-> rows (with-tournament-tiers ctx "esf" :ts-id rows))
     583           22 :    (as-> rows (follow-query/with-followed-players (follow-repository ctx) "esf" (user-id ctx) rows))
     584            2 :    first
     585            2 :    domain->graphql))
     586              : 
     587              : 
     588            4 : (defn esf-ranking-resolver
     589              :  [ctx args _]
     590            4 :  (domain->graphql
     591            8 :   (with-entries-followed
     592            2 :    ctx
     593              :    "esf"
     594              :    :esid
     595           30 :    (esf-repo/find-ranking (esf-repository ctx) (or (:circuit args) "junior") (:categoryId args)))))
     596              : 
     597              : 
     598            4 : (defn fsu-tournaments-resolver
     599              :  [ctx _args _val]
     600            7 :  (let [fsu-repo (get-in ctx [:repos :fsu-postgres-repo])]
     601            6 :    (mapv domain->graphql (fsu-query/get-tournaments fsu-repo))))
     602              : 
     603              : 
     604            4 : (defn fsu-rating-resolver
     605              :  [ctx args _val]
     606            7 :  (let [fsu-repo (get-in ctx [:repos :fsu-postgres-repo])]
     607            2 :    (domain->graphql
     608           13 :     (fsu-query/get-rating fsu-repo (or (:category args) "Absolute") (:snapshotDate args)))))
     609              : 
     610              : 
     611            4 : (defn source-synced-at-resolver
     612              :  "The datasource comes from the source's own repository, so tests that inject
     613              :   only that repository work too."
     614              :  [ctx {:keys [source resource]} _val]
     615            2 :  (let [repo-key (get
     616            7 :                  {"fsu" :fsu-postgres-repo
     617              :                   "psa" :psa-postgres-repo
     618              :                   "esf" :esf-postgres-repo}
     619            1 :                  source)]
     620           11 :    (source-sync-query/synced-at (get-in ctx [:repos repo-key :ds]) source resource)))
     621              : 
     622              : 
     623            4 : (defn event-source-synced-at-resolver
     624              :  [ctx _args val]
     625           16 :  (when (and (:source val) (not= "matchscore" (name (:source val))))
     626           12 :    (source-sync-query/event-synced-at (get-in ctx [:repos :event-postgres-repo :ds]) (:uuid val))))
     627              : 
     628              : 
     629            4 : (defn psa-seasons-resolver
     630              :  [ctx _args _val]
     631            8 :  (psa-query/get-seasons (get-in ctx [:repos :psa-postgres-repo])))
     632              : 
     633              : 
     634            4 : (defn psa-tournaments-resolver
     635              :  [ctx args _val]
     636           21 :  (let [repo (get-in ctx [:repos :psa-postgres-repo])]
     637            6 :    (mapv
     638            3 :     domain->graphql
     639           12 :     (with-tournament-tiers
     640            3 :      ctx
     641              :      "psa"
     642              :      :psa-id
     643           36 :      (psa-query/get-tournaments repo (:season args) (follow-repository ctx) (user-id ctx))))))
     644              : 
     645              : 
     646            4 : (defn psa-tournament-resolver
     647              :  [ctx args _val]
     648           14 :  (let [repo (get-in ctx [:repos :psa-postgres-repo])]
     649           60 :    (some->
     650           24 :      (psa-query/get-tournament repo (:psaId args) (follow-repository ctx) (user-id ctx))
     651            2 :      vector
     652           14 :      (as-> rows (with-tournament-tiers ctx "psa" :psa-id rows))
     653            2 :      first
     654            2 :      domain->graphql)))
     655              : 
     656              : 
     657            4 : (defn psa-tournament-videos-resolver
     658              :  [ctx args _val]
     659            7 :  (let [repo (get-in ctx [:repos :psa-postgres-repo])]
     660            9 :    (mapv domain->graphql (psa-query/get-tournament-videos repo (:psaId args)))))
     661              : 
     662              : 
     663            4 : (defn psa-ranking-resolver
     664              :  [ctx args _val]
     665           14 :  (let [repo (get-in ctx [:repos :psa-postgres-repo])]
     666            4 :    (domain->graphql
     667            4 :     (psa-query/get-ranking
     668            2 :      repo
     669            6 :      (:list args)
     670            6 :      (:snapshotDate args)
     671            6 :      (follow-repository ctx)
     672            6 :      (user-id ctx)))))
     673              : 
     674              : 
     675            4 : (defn my-player-follows-resolver
     676              :  [ctx _args _val]
     677           11 :  (mapv domain->graphql (follow-query/get-followed-players (follow-repository ctx) (user-id ctx))))
     678              : 
     679              : 
     680            4 : (defn player-profile-resolver
     681              :  [ctx {:keys [source id]} _val]
     682            9 :  (some->
     683           10 :    (follow-query/get-player-profile (follow-repository ctx) (user-id ctx) source id)
     684            1 :    domain->graphql))
     685              : 
     686              : 
     687            4 : (defn search-players-resolver
     688              :  [ctx {:keys [source query limit excludeSources]} _val]
     689            2 :  (mapv
     690            1 :   domain->graphql
     691            2 :   (follow-query/search-players
     692            3 :    (follow-repository ctx)
     693            3 :    (user-id ctx)
     694            1 :    source
     695            1 :    query
     696            1 :    limit
     697            1 :    excludeSources)))
     698              : 
     699              : 
     700            4 : (defn global-search-resolver
     701              :  "Players of every source and public events matching the query."
     702              :  [ctx {:keys [query limit]} _val]
     703            4 :  (let [repo (follow-repository ctx)]
     704            5 :    {:players (mapv
     705            1 :               domain->graphql
     706            9 :               (follow-query/search-players repo (user-id ctx) "all" query limit))
     707            2 :     :events  (if repo
     708            2 :                (mapv
     709            1 :                 domain->graphql
     710           10 :                 (search-events/search-events (:ds repo) (:meilisearch repo) query limit))
     711            0 :                [])}))
     712              : 
     713              : 
     714            4 : (defn my-psa-follows-resolver
     715              :  [ctx _args _val]
     716            7 :  (let [repo (get-in ctx [:repos :psa-postgres-repo])]
     717            2 :    (mapv
     718            1 :     domain->graphql
     719            9 :     (psa-query/get-followed-players repo (get-in ctx [:auth-headers :user/uuid])))))
     720              : 
     721              : 
     722            4 : (defn club-courts-resolver
     723              :  "A club's active courts (resources), by name: what an organizer picks from when
     724              :   planning how many courts an event has."
     725              :  [ctx _args val]
     726            7 :  (let [repo (get-in ctx [:repos :resource-postgres-repo])]
     727            8 :    (if-let [club-id (:uuid val)]
     728            3 :      (mapv
     729           10 :       #(domain->graphql (select-keys % [:uuid :public-id :name :resource-type]))
     730            4 :       (resource-query/get-club-resources repo club-id))
     731            0 :      [])))
     732              : 
     733              : 
     734            4 : (defn search-clubs-resolver
     735              :  [ctx args _val]
     736            4 :  (either->resolve
     737           20 :   (c/mlet [pagination (parse-pagination args)]
     738           14 :     (let [club-repo (get-in ctx [:repos :club-postgres-repo])
     739           15 :           filters   (or (:filter args) {})
     740           10 :           result    (club-query/search-clubs club-repo filters pagination)]
     741            4 :       (either/right
     742            2 :        (->
     743            2 :          result
     744           16 :          (update :items #(mapv domain->graphql %))
     745            2 :          domain->graphql))))))
     746              : 
     747              : 
     748            4 : (defn class-resolver
     749              :  [ctx args _val]
     750           21 :  (let [class-repo (get-in ctx [:repos :class-postgres-repo])
     751            9 :        id         (:id args)]
     752            3 :    (->
     753           12 :      (class-query/get-class class-repo id)
     754            3 :      domain->graphql)))
     755              : 
     756              : 
     757            4 : (defn classes-resolver
     758              :  [ctx args _val]
     759            2 :  (either->resolve
     760           10 :   (c/mlet [pagination (parse-pagination args)]
     761            7 :     (let [class-repo (get-in ctx [:repos :class-postgres-repo])
     762            8 :           filters    (or (:filter args) {})
     763            5 :           result     (class-query/search-classes class-repo filters pagination)]
     764            2 :       (either/right
     765            1 :        (->
     766            1 :          result
     767            8 :          (update :items #(mapv domain->graphql %))
     768            1 :          domain->graphql))))))
     769              : 
     770              : 
     771            4 : (defn -primary-club
     772              :  "The primary (first) associated club of an event/template, used to back the
     773              :   legacy singular `club`/`clubId` fields in the many-to-many model."
     774              :  [val]
     775           19 :  (or (:club val) (first (:clubs val))))
     776              : 
     777              : 
     778            4 : (defn template-club-resolver
     779              :  [ctx _args val]
     780           13 :  (or (-primary-club val) (when-let [club-id (:clubId val)] (club-resolver ctx {:id club-id} nil))))
     781              : 
     782              : 
     783            4 : (defn template-club-id-resolver
     784              :  [_ctx _args val]
     785            0 :  (or (:uuid (-primary-club val)) (:clubId val)))
     786              : 
     787              : 
     788            4 : (defn template-clubs-resolver
     789              :  [ctx _args val]
     790            0 :  (or
     791            0 :   (seq (:clubs val))
     792            0 :   (when-let [c (:club val)] [c])
     793            0 :   (when-let [club-id (:clubId val)]
     794            0 :     (some->
     795            0 :       (club-resolver ctx {:id club-id} nil)
     796            0 :       vector))
     797              :   []))
     798              : 
     799              : 
     800            4 : (defn event-club-resolver
     801              :  [ctx _args val]
     802            7 :  (or (-primary-club val) (when-let [club-id (:clubId val)] (club-resolver ctx {:id club-id} nil))))
     803              : 
     804              : 
     805            4 : (defn event-club-id-resolver
     806              :  [_ctx _args val]
     807            9 :  (or (:uuid (-primary-club val)) (:clubId val)))
     808              : 
     809              : 
     810            4 : (defn event-clubs-resolver
     811              :  [ctx _args val]
     812            0 :  (or
     813            0 :   (seq (:clubs val))
     814            0 :   (when-let [c (:club val)] [c])
     815            0 :   (when-let [club-id (:clubId val)]
     816            0 :     (some->
     817            0 :       (club-resolver ctx {:id club-id} nil)
     818            0 :       vector))
     819              :   []))
     820              : 
     821              : 
     822            4 : (defn class-templates-resolver
     823              :  [ctx args _val]
     824            2 :  (either->resolve
     825           10 :   (c/mlet [pagination (parse-pagination args)]
     826            7 :     (let [repo    (get-in ctx [:repos :class-template-postgres-repo])
     827            8 :           filters (or (:filter args) {})
     828            5 :           result  (class-template-query/search-class-templates repo filters pagination)]
     829            2 :       (either/right
     830            1 :        (->
     831            1 :          result
     832            8 :          (update :items #(mapv domain->graphql %))
     833            1 :          domain->graphql))))))
     834              : 
     835              : 
     836              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
     837           14 : (s/def-superfetcher
     838              :  FetchClassTemplatesByTemplate
     839              :  [id]
     840            1 :  (fn [fetchers {:keys [repos]}]
     841            4 :   (let [repo  (:class-template-postgres-repo repos)
     842            4 :         ids   (map :id fetchers)
     843            4 :         all   (class-template-query/get-class-templates-by-template-ids repo ids)
     844            4 :         by-id (group-by-str :template-id all)]
     845           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
     846              : 
     847              : 
     848            4 : (defn template-class-templates-resolver
     849              :  [ctx _args val]
     850            9 :  (s/with-superlifter
     851            3 :   (:superlifter ctx)
     852            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchClassTemplatesByTemplate (:uuid val))))))
     853              : 
     854              : 
     855            4 : (defn- telegram-grant-template-access!
     856              :   [ctx template]
     857            4 :   (let [auth (:auth-headers ctx)
     858            3 :         bot  (:bot ctx)]
     859            1 :     (boolean
     860           16 :      (when (and bot (:user/uuid auth) (:telegram/id auth))
     861            3 :        (let [result (app-telegram-access/grant-template-access!
     862            1 :                      ctx
     863            1 :                      bot
     864            3 :                      (:uuid template)
     865            3 :                      (:user/uuid auth)
     866            3 :                      (:telegram/id auth))]
     867           11 :          (and (either/right? result) (:granted (c/extract result))))))))
     868              : 
     869              : 
     870            4 : (defn- telegram-grant-event-access!
     871              :   [ctx event]
     872            8 :   (let [auth (:auth-headers ctx)
     873            6 :         bot  (:bot ctx)]
     874            2 :     (boolean
     875           12 :      (when (and bot (:user/uuid auth) (:telegram/id auth))
     876            0 :        (let [result (app-telegram-access/grant-event-access!
     877            0 :                      ctx
     878            0 :                      bot
     879            0 :                      (:uuid event)
     880            0 :                      (:user/uuid auth)
     881            0 :                      (:telegram/id auth))]
     882            0 :          (and (either/right? result) (:granted (c/extract result))))))))
     883              : 
     884              : 
     885            4 : (defn event-resolver
     886              :  [ctx args _val]
     887           28 :  (let [repo  (get-in ctx [:repos :event-postgres-repo])
     888           12 :        id    (:id args)
     889           32 :        joins (cond-> [] (executor/selects-field? ctx :Event/club) (conj :club))
     890           20 :        event (or
     891           28 :               (event-query/get-event-by-public-id repo id {:joins joins})
     892           30 :               (when (utils.uuid/uuid-string? id) (event-query/get-event repo id {:joins joins})))]
     893            8 :    (when
     894           30 :      (and
     895            4 :       event
     896           22 :       (or (access-resource/event-readable? ctx event) (telegram-grant-event-access! ctx event)))
     897           12 :      (domain->graphql event))))
     898              : 
     899              : 
     900              : ;; Gallery metadata is fetched only when a query selects images/coverImage.
     901              : ;; Each entity kind is batched into one SQL query, avoiding list N+1 reads.
     902           14 : (s/def-superfetcher
     903              :  FetchEventGallery
     904              :  [id]
     905            1 :  (fn [fetchers env]
     906            5 :   (let [ids       (mapv :id fetchers)
     907            5 :         galleries (media/galleries-for env :event ids)]
     908           15 :     (mapv #(mapv domain->graphql (get galleries (str (:id %)) [])) fetchers))))
     909              : 
     910              : 
     911           14 : (s/def-superfetcher
     912              :  FetchTemplateGallery
     913              :  [id]
     914            1 :  (fn [fetchers env]
     915            5 :   (let [ids       (mapv :id fetchers)
     916            5 :         galleries (media/galleries-for env :template ids)]
     917           15 :     (mapv #(mapv domain->graphql (get galleries (str (:id %)) [])) fetchers))))
     918              : 
     919              : 
     920              : ;; An event's cover is its own first image, else its template's first image.
     921              : ;; Events copy the template gallery only when they are created, so events made
     922              : ;; before the template had images would otherwise show no cover. At most two
     923              : ;; batched queries: event galleries, then templates of the events without one.
     924           14 : (s/def-superfetcher
     925              :  FetchEventCover
     926              :  [id template-id]
     927            1 :  (fn [fetchers env]
     928           10 :   (let [event-galleries    (media/galleries-for env :event (mapv :id fetchers))
     929            9 :         own-cover          #(first (get event-galleries (str (:id %))))
     930            2 :         template-ids       (->>
     931            1 :                              fetchers
     932            3 :                              (remove own-cover)
     933            3 :                              (keep :template-id)
     934            3 :                              (map str)
     935            1 :                              distinct
     936            1 :                              vec)
     937            4 :         template-galleries (if (seq template-ids)
     938            5 :                              (media/galleries-for env :template template-ids)
     939            1 :                              {})]
     940            2 :     (mapv
     941            1 :      (fn [fetcher]
     942            9 :       (some->
     943           10 :         (or
     944            3 :          (own-cover fetcher)
     945            3 :          (when-let [template-id (:template-id fetcher)]
     946            7 :            (first (get template-galleries (str template-id)))))
     947            1 :         domain->graphql))
     948            1 :      fetchers))))
     949              : 
     950              : 
     951            4 : (defn- gallery-promise
     952              :   [ctx fetcher]
     953           17 :   (s/with-superlifter (:superlifter ctx) (sl/->lacinia-promise (s/enqueue! fetcher))))
     954              : 
     955              : 
     956            4 : (defn- cover-promise
     957              :   [ctx fetcher]
     958            9 :   (s/with-superlifter
     959            3 :    (:superlifter ctx)
     960            8 :    (sl/->lacinia-promise (s/unwrap first (s/enqueue! fetcher)))))
     961              : 
     962              : 
     963            4 : (defn event-images-resolver
     964              :  [ctx _args event]
     965            8 :  (gallery-promise ctx (->FetchEventGallery (:uuid event))))
     966              : 
     967              : 
     968            4 : (defn event-cover-image-resolver
     969              :  [ctx _args event]
     970            2 :  (gallery-promise
     971            1 :   ctx
     972           12 :   (->FetchEventCover (:uuid event) (or (:templateId event) (:template-id event)))))
     973              : 
     974              : 
     975            4 : (defn template-images-resolver
     976              :  [ctx _args template]
     977            8 :  (gallery-promise ctx (->FetchTemplateGallery (:uuid template))))
     978              : 
     979              : 
     980            4 : (defn template-cover-image-resolver
     981              :  [ctx _args template]
     982            8 :  (cover-promise ctx (->FetchTemplateGallery (:uuid template))))
     983              : 
     984              : 
     985            4 : (defn events-resolver
     986              :  [ctx args _val]
     987            7 :  (let [repo    (get-in ctx [:repos :event-postgres-repo])
     988           14 :        filters (cond-> (or (:filter args) {})
     989            7 :                  (guest-context? ctx) (assoc :visibility {:eq "public"}))]
     990            2 :    (either->resolve
     991           17 :     (c/mlet [pagination (parse-pagination args)
     992            5 :              result     (event-query/search-events repo filters pagination)]
     993            2 :       (c/return
     994            1 :        (->
     995            1 :          result
     996            8 :          (update :items #(mapv domain->graphql %))
     997            1 :          domain->graphql))))))
     998              : 
     999              : 
    1000            4 : (defn public-events-resolver
    1001              :  [ctx args _val]
    1002            2 :  (either->resolve
    1003           17 :   (c/mlet [pagination (parse-pagination args)
    1004            2 :            result     (event-query/search-public-events
    1005            6 :                        (get-in ctx [:repos :event-postgres-repo])
    1006            8 :                        (or (:filter args) {})
    1007            1 :                        pagination)]
    1008            2 :     (c/return
    1009            1 :      (->
    1010            1 :        result
    1011            8 :        (update :items #(mapv domain->graphql %))
    1012            1 :        domain->graphql)))))
    1013              : 
    1014              : 
    1015           37 : (defn- activity-user-id [ctx args] (or (:userId args) (get-in ctx [:auth-headers :user/uuid])))
    1016              : 
    1017              : 
    1018            4 : (defn- readable-template-items
    1019              :   [ctx items]
    1020           14 :   (filterv (partial access-resource/template-readable? ctx) items))
    1021              : 
    1022              : 
    1023            4 : (defn- profile-activity-filter
    1024              :   [ctx args filters]
    1025           21 :   (let [viewer-id  (get-in ctx [:auth-headers :user/uuid])
    1026           12 :         profile-id (activity-user-id ctx args)]
    1027           43 :     (cond (nil? viewer-id)         (assoc (or filters {}) :visibility {:eq "public"})
    1028           25 :           (= viewer-id profile-id) (or filters {})
    1029           27 :           :else                    (assoc (or filters {}) :profile-visible-to-user-id viewer-id))))
    1030              : 
    1031              : 
    1032            4 : (defn- event-for-match
    1033              :   [ctx match]
    1034            6 :   (let [repo (:event-postgres-repo (:repos ctx))]
    1035            8 :     (if-let [event-id (:event-id match)]
    1036            7 :       (event-query/get-event repo event-id {:joins []})
    1037           28 :       (some->
    1038            3 :         (:stage-id match)
    1039            1 :         vector
    1040            2 :         (->>
    1041            2 :           (event-query/get-events-by-stage-ids repo))
    1042            1 :         first
    1043              :         :event))))
    1044              : 
    1045              : 
    1046            4 : (defn- readable-match-items
    1047              :   [ctx items]
    1048           11 :   (filterv #(access-resource/event-readable? ctx (event-for-match ctx %)) items))
    1049              : 
    1050              : 
    1051            4 : (defn- with-user-relation
    1052              :   "Marks each item with how user-id relates to it: creator and/or participant admin.
    1053              :    find-user-participants returns the user's participant rows for the given item ids,
    1054              :    owner-key is the item id on those rows. Guests get no relation flags, matching the
    1055              :    private createdBy and roles fields."
    1056              :   [ctx user-id owner-key find-user-participants items]
    1057           32 :   (if (or (guest-context? ctx) (empty? items))
    1058            3 :     items
    1059            6 :     (let [admin-ids (->>
    1060           21 :                       (find-user-participants (mapv :uuid items) user-id)
    1061           30 :                       (filter #(some #{"admin"} (:roles %)))
    1062           24 :                       (map #(str (owner-key %)))
    1063            3 :                       set)]
    1064            6 :       (mapv
    1065            3 :        (fn [item]
    1066           15 :         (assoc item
    1067           27 :          :user-is-creator (= (str (:created-by item)) (str user-id))
    1068           24 :          :user-is-admin   (contains? admin-ids (str (:uuid item)))))
    1069            3 :        items))))
    1070              : 
    1071              : 
    1072            4 : (defn- with-user-event-relation
    1073              :   [ctx user-id events]
    1074            6 :   (with-user-relation
    1075            2 :    ctx
    1076            2 :    user-id
    1077              :    :event-id
    1078            4 :    (partial
    1079            2 :     event-participant-query/get-user-participants-by-event-ids
    1080           12 :     (get-in ctx [:repos :event-participant-postgres-repo]))
    1081            2 :    events))
    1082              : 
    1083              : 
    1084            4 : (defn- with-user-template-relation
    1085              :   [ctx user-id templates]
    1086            6 :   (with-user-relation
    1087            2 :    ctx
    1088            2 :    user-id
    1089              :    :template-id
    1090            4 :    (partial
    1091            2 :     template-participant-query/get-user-participants-by-template-ids
    1092           12 :     (get-in ctx [:repos :template-participant-postgres-repo]))
    1093            2 :    templates))
    1094              : 
    1095              : 
    1096            4 : (defn user-events-resolver
    1097              :  [ctx args _val]
    1098           10 :  (let [user-id (activity-user-id ctx args)]
    1099            4 :    (either->resolve
    1100           34 :     (c/mlet [pagination (parse-pagination args)
    1101            4 :              result     (event-query/search-user-events
    1102           12 :                          (get-in ctx [:repos :event-postgres-repo])
    1103            2 :                          user-id
    1104           23 :                          (cond-> (profile-activity-filter ctx args (:filter args))
    1105            8 :                            (:hostedOnly args) (assoc :hosted-user-id user-id))
    1106            2 :                          pagination
    1107            8 :                          (boolean (:includeAdminRole args)))]
    1108            4 :       (c/return
    1109            2 :        (->
    1110            2 :          result
    1111           18 :          (update :items #(with-user-event-relation ctx user-id %))
    1112           16 :          (update :items #(mapv domain->graphql %))
    1113            2 :          domain->graphql))))))
    1114              : 
    1115              : 
    1116            4 : (defn- scoreboard-place
    1117              :   "Overall place and field size of `participant-id` in one class scoreboard,
    1118              :    or nil when the participant is not on it. The last stage's groups/brackets
    1119              :    are read in order (as on the results tab and the Telegram results post), so
    1120              :    a place in the second group continues after the first group's rows."
    1121              :   [scoreboard participant-id]
    1122            4 :   (let [pid   (str participant-id)
    1123            4 :         units (mapcat :results scoreboard)
    1124            3 :         place (loop [[unit & more] units
    1125              :                      offset        0]
    1126            3 :                 (when unit
    1127            7 :                   (if-let [place (some
    1128            1 :                                   (fn [{:keys [place participant]}]
    1129            2 :                                    (when
    1130            1 :                                      (=
    1131            1 :                                       pid
    1132           17 :                                       (some->
    1133            1 :                                         participant
    1134              :                                         :uuid
    1135            1 :                                         str))
    1136            1 :                                      place))
    1137            3 :                                   (:results unit))]
    1138            3 :                     (+ offset place)
    1139            1 :                     (recur more (+ offset (count (:results unit)))))))]
    1140            3 :     (when place
    1141            4 :       {:place place
    1142            5 :        :participant-count (count (mapcat :results units))})))
    1143              : 
    1144              : 
    1145            4 : (defn- event-user-places
    1146              :   "Final place of the profile user in each class of a completed event, in class
    1147              :    order. Empty for other states, guests of the scoreboard, or users without a
    1148              :    participant record."
    1149              :   [ctx event]
    1150            8 :   (let [user-id (or (:profileUserId event) (:profile-user-id event))]
    1151           13 :     (if-not (and (= "completed" (:state event)) user-id)
    1152            1 :       []
    1153           17 :       (let [participant-id (some->
    1154            2 :                              (participant-query/get-participants-by-user
    1155            6 :                               (get-in ctx [:repos :participant-postgres-repo])
    1156            1 :                               user-id)
    1157            1 :                              first
    1158              :                              :uuid)
    1159            3 :             classes        (when participant-id
    1160            2 :                              (class-query/get-classes-by-event-id
    1161            6 :                               (get-in ctx [:repos :class-postgres-repo])
    1162            3 :                               (:uuid event)))]
    1163            2 :         (into
    1164            1 :          []
    1165            2 :          (keep
    1166            1 :           (fn [class]
    1167           14 :            (let [result (app-scoreboard/execute! ctx (str (:uuid event)) (str (:uuid class)))]
    1168            5 :              (when (either/right? result)
    1169            9 :                (some->
    1170            6 :                  (scoreboard-place (c/extract result) participant-id)
    1171            1 :                  (merge
    1172            9 :                   {:class-id        (str (:uuid class))
    1173            3 :                    :class-public-id (:public-id class)
    1174            3 :                    :class-name      (:name class)}))))))
    1175            1 :          classes)))))
    1176              : 
    1177              : 
    1178            4 : (defn event-user-place-resolver
    1179              :  [ctx _args event]
    1180           22 :  (some->>
    1181            4 :    (event-user-places ctx event)
    1182            3 :    (map :place)
    1183            1 :    seq
    1184            2 :    (apply min)))
    1185              : 
    1186              : 
    1187            4 : (defn event-user-places-resolver
    1188              :  [ctx _args event]
    1189            6 :  (domain->graphql (event-user-places ctx event)))
    1190              : 
    1191              : 
    1192            4 : (defn user-participating-events-resolver
    1193              :  [ctx args _val]
    1194            2 :  (either->resolve
    1195           17 :   (c/mlet [pagination (parse-pagination args)
    1196            2 :            result     (event-query/search-user-participating-events
    1197            6 :                        (get-in ctx [:repos :event-postgres-repo])
    1198            4 :                        (activity-user-id ctx args)
    1199            7 :                        (profile-activity-filter ctx args (:filter args))
    1200            1 :                        pagination)]
    1201            2 :     (c/return
    1202            5 :      (let [user-id (activity-user-id ctx args)]
    1203            1 :        (->
    1204            1 :          result
    1205            4 :          (update
    1206              :           :items
    1207            3 :           #(mapv
    1208            1 :             (fn [event]
    1209            5 :              (assoc event :profile-user-id user-id))
    1210              :             %))
    1211            8 :          (update :items #(mapv domain->graphql %))
    1212            1 :          domain->graphql))))))
    1213              : 
    1214              : 
    1215            4 : (defn user-participating-templates-resolver
    1216              :  [ctx args _val]
    1217            2 :  (either->resolve
    1218           17 :   (c/mlet [pagination (parse-pagination args)
    1219            2 :            result     (template-query/search-user-participating-templates
    1220            6 :                        (get-in ctx [:repos :template-postgres-repo])
    1221            4 :                        (activity-user-id ctx args)
    1222            7 :                        (profile-activity-filter ctx args (:filter args))
    1223            1 :                        pagination
    1224            4 :                        (boolean (:playerOnly args)))]
    1225            2 :     (c/return
    1226            1 :      (->
    1227            1 :        result
    1228           11 :        (update :items #(mapv domain->graphql (readable-template-items ctx %)))
    1229            1 :        domain->graphql)))))
    1230              : 
    1231              : 
    1232            4 : (defn user-matches-resolver
    1233              :  [ctx args _val]
    1234            2 :  (either->resolve
    1235           17 :   (c/mlet [pagination (parse-pagination args)
    1236            2 :            result     (match-query/search-user-matches
    1237            6 :                        (get-in ctx [:repos :match-postgres-repo])
    1238            4 :                        (activity-user-id ctx args)
    1239            8 :                        (or (:filter args) {})
    1240            1 :                        pagination)]
    1241            2 :     (c/return
    1242            1 :      (->
    1243            1 :        result
    1244           11 :        (update :items #(mapv domain->graphql (readable-match-items ctx %)))
    1245            1 :        domain->graphql)))))
    1246              : 
    1247              : 
    1248            4 : (defn match-resolver
    1249              :  [ctx {:keys [eventId id]} _val]
    1250            4 :  (let [repos      (:repos ctx)
    1251            6 :        match      (match-query/get-match (:match-postgres-repo repos) id)
    1252            3 :        event-repo (:event-postgres-repo repos)
    1253            4 :        requested  (or
    1254            7 :                    (event-query/get-event-by-public-id event-repo eventId {:joins []})
    1255            0 :                    (when (utils.uuid/uuid-string? eventId)
    1256            0 :                      (event-query/get-event event-repo eventId {:joins []})))
    1257            4 :        actual-id  (or
    1258            3 :                    (:event-id match)
    1259              :                    (some->
    1260            0 :                      (:stage-id match)
    1261            0 :                      vector
    1262            0 :                      (->>
    1263            0 :                        (event-query/get-events-by-stage-ids event-repo))
    1264            0 :                      first
    1265              :                      :event
    1266              :                      :uuid))]
    1267            2 :    (when
    1268           11 :      (and
    1269            1 :       match
    1270            1 :       requested
    1271            1 :       (=
    1272            5 :        (str (:uuid requested))
    1273            8 :        (some->
    1274            1 :          actual-id
    1275            1 :          str))
    1276            3 :       (access-resource/event-readable? ctx requested))
    1277            3 :      (domain->graphql match))))
    1278              : 
    1279              : 
    1280            4 : (defn stage-resolver
    1281              :  [ctx args _val]
    1282            7 :  (let [repo (get-in ctx [:repos :stage-postgres-repo])
    1283            3 :        id   (:id args)]
    1284            1 :    (->
    1285            4 :      (stage-query/get-stage repo id)
    1286            1 :      domain->graphql)))
    1287              : 
    1288              : 
    1289            4 : (defn stages-resolver
    1290              :  [ctx args _val]
    1291            2 :  (either->resolve
    1292           10 :   (c/mlet [pagination (parse-pagination args)]
    1293            7 :     (let [repo    (get-in ctx [:repos :stage-postgres-repo])
    1294            7 :           filters (or (:filter args) {})
    1295            5 :           result  (stage-query/search-stages repo filters pagination)]
    1296            2 :       (either/right
    1297            1 :        (->
    1298            1 :          result
    1299            8 :          (update :items #(mapv domain->graphql %))
    1300            1 :          domain->graphql))))))
    1301              : 
    1302              : 
    1303              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1304           32 : (s/def-superfetcher
    1305              :  FetchParticipantsByEvent
    1306              :  [id]
    1307            2 :  (fn [fetchers {:keys [repos]}]
    1308            8 :   (let [repo  (:event-participant-postgres-repo repos)
    1309            8 :         ids   (map :id fetchers)
    1310            8 :         all   (event-participant-query/get-participants-by-event-ids repo ids)
    1311            8 :         by-id (group-by-str :event-id all)]
    1312           28 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1313              : 
    1314              : 
    1315            4 : (defn event-participants-resolver
    1316              :  [ctx _args val]
    1317            9 :  (s/with-superlifter
    1318            3 :   (:superlifter ctx)
    1319            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchParticipantsByEvent (:uuid val))))))
    1320              : 
    1321              : 
    1322              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1323           32 : (s/def-superfetcher
    1324              :  FetchClassesByEvent
    1325              :  [id]
    1326            2 :  (fn [fetchers {:keys [repos]}]
    1327            8 :   (let [repo  (:class-postgres-repo repos)
    1328            8 :         ids   (map :id fetchers)
    1329            8 :         all   (class-query/get-classes-by-event-ids repo ids)
    1330            8 :         by-id (group-by-str :event-id all)]
    1331           28 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1332              : 
    1333              : 
    1334            4 : (defn event-classes-resolver
    1335              :  [ctx _args val]
    1336            9 :  (s/with-superlifter
    1337            3 :   (:superlifter ctx)
    1338            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchClassesByEvent (:uuid val))))))
    1339              : 
    1340              : 
    1341              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1342           32 : (s/def-superfetcher
    1343              :  FetchParticipantsByClass
    1344              :  [id max-players]
    1345            2 :  (fn [fetchers {:keys [repos]}]
    1346            8 :   (let [repo  (:class-participant-postgres-repo repos)
    1347            8 :         ids   (map :id fetchers)
    1348            8 :         all   (class-participant-query/get-class-participants-by-class-ids repo ids)
    1349            8 :         by-id (group-by-str :class-id all)]
    1350            4 :     (mapv
    1351            2 :      (fn [{:keys [id max-players]}]
    1352            4 :       (mapv
    1353            2 :        domain->graphql
    1354           16 :        (class-participant-entity/with-queue-positions max-players (get-str-key by-id id []))))
    1355            2 :      fetchers))))
    1356              : 
    1357              : 
    1358            4 : (defn class-participants-resolver
    1359              :  [ctx _args val]
    1360            9 :  (s/with-superlifter
    1361            3 :   (:superlifter ctx)
    1362           12 :   (sl/->lacinia-promise (s/enqueue! (->FetchParticipantsByClass (:uuid val) (:maxPlayers val))))))
    1363              : 
    1364              : 
    1365              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1366           14 : (s/def-superfetcher
    1367              :  FetchParticipantsByTemplate
    1368              :  [id]
    1369            1 :  (fn [fetchers {:keys [repos]}]
    1370            4 :   (let [repo  (:template-participant-postgres-repo repos)
    1371            4 :         ids   (map :id fetchers)
    1372            4 :         all   (template-participant-query/get-participants-by-template-ids repo ids)
    1373            4 :         by-id (group-by-str :template-id all)]
    1374           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1375              : 
    1376              : 
    1377            4 : (defn template-participants-resolver
    1378              :  [ctx _args val]
    1379            9 :  (s/with-superlifter
    1380            3 :   (:superlifter ctx)
    1381            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchParticipantsByTemplate (:uuid val))))))
    1382              : 
    1383              : 
    1384              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1385           32 : (s/def-superfetcher
    1386              :  FetchParticipantsByClassTemplate
    1387              :  [id]
    1388            2 :  (fn [fetchers {:keys [repos]}]
    1389            8 :   (let [repo  (:class-template-participant-postgres-repo repos)
    1390            8 :         ids   (map :id fetchers)
    1391            8 :         all   (class-template-participant-query/get-participants-by-class-template-ids repo ids)
    1392            8 :         by-id (group-by-str :class-template-id all)]
    1393           28 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1394              : 
    1395              : 
    1396            4 : (defn class-template-participants-resolver
    1397              :  [ctx _args val]
    1398            9 :  (s/with-superlifter
    1399            3 :   (:superlifter ctx)
    1400            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchParticipantsByClassTemplate (:uuid val))))))
    1401              : 
    1402              : 
    1403            4 : (defn template-resolver
    1404              :  [ctx args _val]
    1405           14 :  (let [repo     (get-in ctx [:repos :template-postgres-repo])
    1406            6 :        id       (:id args)
    1407           20 :        joins    (cond-> [] (executor/selects-field? ctx :Template/club) (conj :club))
    1408            8 :        template (or
    1409           14 :                  (template-query/get-template-by-public-id repo id {:joins joins})
    1410           12 :                  (template-query/get-template repo id {:joins joins}))]
    1411            6 :    (when template
    1412            4 :      (when
    1413            8 :        (or
    1414            8 :         (access-resource/template-readable? ctx template)
    1415            3 :         (telegram-grant-template-access! ctx template))
    1416            6 :        (domain->graphql template)))))
    1417              : 
    1418              : 
    1419              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1420           25 : (s/def-superfetcher
    1421              :  FetchTemplateById
    1422              :  [id]
    1423            1 :  (fn [fetchers {:keys [repos]}]
    1424            4 :   (let [repo  (:template-postgres-repo repos)
    1425            6 :         ids   (distinct (map :id fetchers))
    1426            4 :         all   (template-query/get-templates-by-ids repo ids)
    1427            4 :         by-id (group-by-str :uuid all)]
    1428           13 :     (mapv #(first (get-str-key by-id (:id %) [])) fetchers))))
    1429              : 
    1430              : 
    1431            4 : (defn event-template-resolver
    1432              :  "Resolves the template an event was created from. A template the viewer cannot
    1433              :   read resolves to nil, so a public event never exposes a private template."
    1434              :  [ctx _args val]
    1435            9 :  (when-let [template-id (:templateId val)]
    1436            9 :    (s/with-superlifter
    1437            3 :     (:superlifter ctx)
    1438            2 :     (sl/->lacinia-promise
    1439            2 :      (s/unwrap
    1440            1 :       (fn [template]
    1441            9 :        (when (access-resource/template-readable? ctx template) (domain->graphql template)))
    1442            7 :       (s/enqueue! (->FetchTemplateById (str template-id))))))))
    1443              : 
    1444              : 
    1445            4 : (defn event-telegram-links-resolver
    1446              :  [ctx _args val]
    1447            9 :  (if-not (access-resource/event-manageable? ctx (:uuid val))
    1448            1 :    []
    1449            2 :    (mapv
    1450            1 :     domain->graphql
    1451            9 :     (telegram-link-query/list-links-for-resource (:repos ctx) :event (:uuid val)))))
    1452              : 
    1453              : 
    1454            4 : (defn- graphql-event->source-event
    1455              :   [val]
    1456            7 :   {:uuid        (:uuid val)
    1457            3 :    :source      (:source val)
    1458            3 :    :rankedin-id (:rankedinId val)})
    1459              : 
    1460              : 
    1461            4 : (defn event-source-url-resolver
    1462              :  [ctx _args val]
    1463            2 :  (event-source-link/source-url
    1464            7 :   (get-in ctx [:repos :event-postgres-repo :ds])
    1465            3 :   (graphql-event->source-event val)))
    1466              : 
    1467              : 
    1468            4 : (defn event-psa-id-resolver
    1469              :  [ctx _args val]
    1470            2 :  (event-source-link/psa-id
    1471            7 :   (get-in ctx [:repos :event-postgres-repo :ds])
    1472            3 :   (graphql-event->source-event val)))
    1473              : 
    1474              : 
    1475            4 : (defn event-stage1-draws-revision-resolver
    1476              :  [ctx _args val]
    1477           12 :  (draws-revision/revision (get-in ctx [:repos :event-postgres-repo :ds]) (:uuid val)))
    1478              : 
    1479              : 
    1480            4 : (defn template-telegram-links-resolver
    1481              :  [ctx _args val]
    1482            9 :  (if-not (access-resource/template-manageable? ctx (:uuid val))
    1483            1 :    []
    1484            2 :    (mapv
    1485            1 :     domain->graphql
    1486            9 :     (telegram-link-query/list-links-for-resource (:repos ctx) :template (:uuid val)))))
    1487              : 
    1488              : 
    1489            4 : (defn my-telegram-links-resolver
    1490              :  [ctx _args _val]
    1491            4 :  (if (guest-context? ctx)
    1492            0 :    []
    1493            2 :    (mapv
    1494            1 :     domain->graphql
    1495            2 :     (telegram-link-query/list-links-for-owner
    1496            3 :      (:repos ctx)
    1497            6 :      (get-in ctx [:auth-headers :user/uuid])))))
    1498              : 
    1499              : 
    1500            4 : (defn my-unlinked-telegram-resources-resolver
    1501              :  [ctx _args _val]
    1502            4 :  (if (guest-context? ctx)
    1503            0 :    []
    1504            2 :    (mapv
    1505            1 :     domain->graphql
    1506            2 :     (telegram-link-query/list-unlinked-for-owner
    1507            3 :      (:repos ctx)
    1508            6 :      (get-in ctx [:auth-headers :user/uuid])))))
    1509              : 
    1510              : 
    1511            4 : (defn template-automation-resolver
    1512              :  [ctx _args val]
    1513            5 :  (when-not (guest-context? ctx)
    1514            2 :    (domain->graphql
    1515            2 :     (automation-db/status
    1516            7 :      (get-in ctx [:repos :template-postgres-repo :ds])
    1517            3 :      (:uuid val)
    1518            3 :      (:automaticEventCreation val)))))
    1519              : 
    1520              : 
    1521            4 : (defn event-telegram-chat-messages-resolver
    1522              :  [ctx _args val]
    1523            0 :  (if (guest-context? ctx)
    1524            0 :    []
    1525            0 :    (let [repo (get-in ctx [:repos :telegram-chat-message-postgres-repo])]
    1526            0 :      (mapv domain->graphql (telegram-chat-message-repo/find-by-event-id repo (:uuid val))))))
    1527              : 
    1528              : 
    1529            4 : (defn template-telegram-chat-messages-resolver
    1530              :  [ctx _args val]
    1531            0 :  (if (guest-context? ctx)
    1532            0 :    []
    1533            0 :    (let [repo (get-in ctx [:repos :telegram-chat-message-postgres-repo])]
    1534            0 :      (mapv domain->graphql (telegram-chat-message-repo/find-by-template-id repo (:uuid val))))))
    1535              : 
    1536              : 
    1537            4 : (defn search-templates-resolver
    1538              :  [ctx args _val]
    1539            4 :  (either->resolve
    1540           34 :   (c/mlet [pagination (parse-pagination args)
    1541            4 :            result     (template-query/search-templates
    1542           12 :                        (get-in ctx [:repos :template-postgres-repo])
    1543           23 :                        (cond-> (or (:filter args) {})
    1544           10 :                          (guest-context? ctx) (assoc :visibility {:eq "public"}))
    1545            2 :                        pagination)]
    1546            4 :     (c/return
    1547            2 :      (->
    1548            2 :        result
    1549            8 :        (update
    1550              :         :items
    1551           20 :         #(mapv domain->graphql (filterv (partial access-resource/template-readable? ctx) %)))
    1552            2 :        domain->graphql)))))
    1553              : 
    1554              : 
    1555            4 : (defn user-templates-resolver
    1556              :  [ctx args _val]
    1557           10 :  (let [user-id (activity-user-id ctx args)]
    1558            4 :    (either->resolve
    1559           34 :     (c/mlet [pagination (parse-pagination args)
    1560            4 :              result     (template-query/search-user-templates
    1561           12 :                          (get-in ctx [:repos :template-postgres-repo])
    1562            2 :                          user-id
    1563           23 :                          (cond-> (profile-activity-filter ctx args (:filter args))
    1564            8 :                            (:hostedOnly args) (assoc :hosted-user-id user-id))
    1565            2 :                          pagination
    1566            8 :                          (boolean (:includeAdminRole args)))]
    1567            4 :       (c/return
    1568            2 :        (->
    1569            2 :          result
    1570           24 :          (update :items #(with-user-template-relation ctx user-id (readable-template-items ctx %)))
    1571           16 :          (update :items #(mapv domain->graphql %))
    1572            2 :          domain->graphql))))))
    1573              : 
    1574              : 
    1575              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1576           24 : (s/def-superfetcher
    1577              :  FetchStagesByClass
    1578              :  [id]
    1579            2 :  (fn [fetchers {:keys [repos]}]
    1580            8 :   (let [repo  (:stage-postgres-repo repos)
    1581            8 :         ids   (map :id fetchers)
    1582            8 :         all   (stage-query/get-stages-by-class-ids repo ids)
    1583            8 :         by-id (group-by-str :class-id all)]
    1584           28 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1585              : 
    1586              : 
    1587            4 : (defn stages-by-class-resolver
    1588              :  [ctx _args val]
    1589           18 :  (s/with-superlifter
    1590            6 :   (:superlifter ctx)
    1591           18 :   (sl/->lacinia-promise (s/enqueue! (->FetchStagesByClass (:uuid val))))))
    1592              : 
    1593              : 
    1594              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1595           14 : (s/def-superfetcher
    1596              :  FetchDrawsByStage
    1597              :  [id]
    1598            1 :  (fn [fetchers {:keys [repos]}]
    1599            4 :   (let [repo  (:draw-postgres-repo repos)
    1600            4 :         ids   (map :id fetchers)
    1601            4 :         all   (draw-query/get-draws-by-stage-ids repo ids)
    1602            4 :         by-id (group-by-str :stage-id all)]
    1603           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1604              : 
    1605              : 
    1606            4 : (defn draws-by-stage-resolver
    1607              :  [ctx _args val]
    1608            9 :  (s/with-superlifter
    1609            3 :   (:superlifter ctx)
    1610            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchDrawsByStage (:uuid val))))))
    1611              : 
    1612              : 
    1613              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1614           14 : (s/def-superfetcher
    1615              :  FetchGroupsByDraw
    1616              :  [id]
    1617            1 :  (fn [fetchers {:keys [repos]}]
    1618            4 :   (let [repo  (:group-postgres-repo repos)
    1619            4 :         ids   (map :id fetchers)
    1620            4 :         all   (group-query/get-groups-by-draw-ids repo ids)
    1621            4 :         by-id (group-by-str :draw-id all)]
    1622           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1623              : 
    1624              : 
    1625            4 : (defn groups-by-draw-resolver
    1626              :  [ctx _args val]
    1627            9 :  (s/with-superlifter
    1628            3 :   (:superlifter ctx)
    1629            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchGroupsByDraw (:uuid val))))))
    1630              : 
    1631              : 
    1632              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1633           14 : (s/def-superfetcher
    1634              :  FetchBracketsByDraw
    1635              :  [id]
    1636            1 :  (fn [fetchers {:keys [repos]}]
    1637            4 :   (let [repo  (:bracket-postgres-repo repos)
    1638            4 :         ids   (map :id fetchers)
    1639            4 :         all   (bracket-query/get-brackets-by-draw-ids repo ids)
    1640            4 :         by-id (group-by-str :draw-id all)]
    1641           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1642              : 
    1643              : 
    1644            4 : (defn brackets-by-draw-resolver
    1645              :  [ctx _args val]
    1646            9 :  (s/with-superlifter
    1647            3 :   (:superlifter ctx)
    1648            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchBracketsByDraw (:uuid val))))))
    1649              : 
    1650              : 
    1651              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1652           14 : (s/def-superfetcher
    1653              :  FetchBracketRoundsByBracket
    1654              :  [id]
    1655            1 :  (fn [fetchers {:keys [repos]}]
    1656            4 :   (let [repo  (:bracket-round-postgres-repo repos)
    1657            4 :         ids   (map :id fetchers)
    1658            4 :         all   (bracket-round-query/get-bracket-rounds-by-bracket-ids repo ids)
    1659            4 :         by-id (group-by-str :bracket-id all)]
    1660           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1661              : 
    1662              : 
    1663            4 : (defn bracket-rounds-by-bracket-resolver
    1664              :  [ctx _args val]
    1665            9 :  (s/with-superlifter
    1666            3 :   (:superlifter ctx)
    1667            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchBracketRoundsByBracket (:uuid val))))))
    1668              : 
    1669              : 
    1670              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1671           14 : (s/def-superfetcher
    1672              :  FetchBracketMatchesByRound
    1673              :  [id]
    1674            1 :  (fn [fetchers {:keys [repos]}]
    1675            4 :   (let [repo  (:bracket-match-postgres-repo repos)
    1676            4 :         ids   (map :id fetchers)
    1677            4 :         all   (bracket-match-query/get-bracket-matches-by-round-ids repo ids)
    1678            4 :         by-id (group-by-str :bracket-round-id all)]
    1679           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1680              : 
    1681              : 
    1682            4 : (defn bracket-matches-by-round-resolver
    1683              :  [ctx _args val]
    1684            9 :  (s/with-superlifter
    1685            3 :   (:superlifter ctx)
    1686            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchBracketMatchesByRound (:uuid val))))))
    1687              : 
    1688              : 
    1689              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1690           14 : (s/def-superfetcher
    1691              :  FetchBracketMatchSlotsByMatch
    1692              :  [id]
    1693            1 :  (fn [fetchers {:keys [repos]}]
    1694            4 :   (let [repo  (:bracket-match-slot-postgres-repo repos)
    1695            4 :         ids   (map :id fetchers)
    1696            4 :         all   (bracket-match-slot-query/get-bracket-match-slots-by-match-ids repo ids)
    1697            4 :         by-id (group-by-str :bracket-match-id all)]
    1698           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1699              : 
    1700              : 
    1701            4 : (defn bracket-match-slots-by-match-resolver
    1702              :  [ctx _args val]
    1703            9 :  (s/with-superlifter
    1704            3 :   (:superlifter ctx)
    1705            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchBracketMatchSlotsByMatch (:uuid val))))))
    1706              : 
    1707              : 
    1708              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1709           14 : (s/def-superfetcher
    1710              :  FetchSeriesByBracketMatch
    1711              :  [id]
    1712            1 :  (fn [fetchers {:keys [repos]}]
    1713            4 :   (let [repo  (:series-postgres-repo repos)
    1714            4 :         ids   (map :id fetchers)
    1715            4 :         all   (series-query/get-series-by-bracket-match-ids repo ids)
    1716            4 :         by-id (group-by-str :bracket-match-id all)]
    1717           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1718              : 
    1719              : 
    1720            4 : (defn bracket-match-series-resolver
    1721              :  [ctx _args val]
    1722            9 :  (s/with-superlifter
    1723            3 :   (:superlifter ctx)
    1724            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchSeriesByBracketMatch (:uuid val))))))
    1725              : 
    1726              : 
    1727              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1728           14 : (s/def-superfetcher
    1729              :  FetchMatchResultByBracketMatch
    1730              :  [id]
    1731            1 :  (fn [fetchers {:keys [repos]}]
    1732            4 :   (let [repo  (:match-result-postgres-repo repos)
    1733            4 :         ids   (map :id fetchers)
    1734            4 :         all   (match-result-query/get-match-results-by-bracket-match-ids repo ids)
    1735            4 :         by-id (group-by-str :bracket-match-id all)]
    1736           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1737              : 
    1738              : 
    1739            4 : (defn bracket-match-result-resolver
    1740              :  [ctx _args val]
    1741            9 :  (s/with-superlifter
    1742            3 :   (:superlifter ctx)
    1743            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchResultByBracketMatch (:uuid val))))))
    1744              : 
    1745              : 
    1746              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1747           14 : (s/def-superfetcher
    1748              :  FetchMatchSegmentsByBracketMatch
    1749              :  [id]
    1750            1 :  (fn [fetchers {:keys [repos]}]
    1751            4 :   (let [repo  (:match-segment-postgres-repo repos)
    1752            4 :         ids   (map :id fetchers)
    1753            4 :         all   (match-segment-query/get-match-segments-by-bracket-match-ids repo ids)
    1754            4 :         by-id (group-by-str :bracket-match-id all)]
    1755           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1756              : 
    1757              : 
    1758            4 : (defn bracket-match-segments-resolver
    1759              :  [ctx _args val]
    1760            9 :  (s/with-superlifter
    1761            3 :   (:superlifter ctx)
    1762            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchSegmentsByBracketMatch (:uuid val))))))
    1763              : 
    1764              : 
    1765              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1766           32 : (s/def-superfetcher
    1767              :  FetchMatchByBracketMatch
    1768              :  [id]
    1769            2 :  (fn [fetchers {:keys [repos]}]
    1770            8 :   (let [repo  (:match-postgres-repo repos)
    1771            8 :         ids   (map :id fetchers)
    1772            8 :         all   (match-query/get-matches-by-bracket-match-ids repo ids)
    1773            8 :         by-id (group-by-str :bracket-match-id all)]
    1774           30 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1775              : 
    1776              : 
    1777            4 : (defn bracket-match-match-resolver
    1778              :  [ctx _args val]
    1779            9 :  (s/with-superlifter
    1780            3 :   (:superlifter ctx)
    1781            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchByBracketMatch (:uuid val))))))
    1782              : 
    1783              : 
    1784              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1785           81 : (s/def-superfetcher
    1786              :  FetchParticipantById
    1787              :  [id]
    1788            5 :  (fn [fetchers {:keys [repos]}]
    1789           20 :   (let [repo  (:participant-postgres-repo repos)
    1790           20 :         ids   (map :id fetchers)
    1791           20 :         all   (participant-query/get-participants-by-ids repo ids)
    1792           20 :         by-id (group-by-str :uuid all)]
    1793           75 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1794              : 
    1795              : 
    1796            4 : (defn participant-resolver
    1797              :  [ctx _args val]
    1798           27 :  (s/with-superlifter
    1799            9 :   (:superlifter ctx)
    1800            6 :   (sl/->lacinia-promise
    1801           33 :    (s/enqueue! (->FetchParticipantById (or (:participantId val) (:participant-id val)))))))
    1802              : 
    1803              : 
    1804           45 : (s/def-superfetcher
    1805              :  FetchUserById
    1806              :  [id]
    1807            3 :  (fn [fetchers {:keys [repos]}]
    1808           12 :   (let [repo  (:user-postgres-repo repos)
    1809           12 :         ids   (map :id fetchers)
    1810           12 :         all   (user-query/get-users-by-ids repo ids)
    1811           12 :         by-id (group-by-str :uuid all)]
    1812           45 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1813              : 
    1814              : 
    1815            4 : (defn user-by-id-resolver
    1816              :  [ctx _args val]
    1817           18 :  (s/with-superlifter
    1818            6 :   (:superlifter ctx)
    1819           18 :   (sl/->lacinia-promise (s/enqueue! (->FetchUserById (:userId val))))))
    1820              : 
    1821              : 
    1822            4 : (defn host-resolver
    1823              :  [ctx _args val]
    1824            9 :  (when-let [id (:hostUserId val)]
    1825            9 :    (s/with-superlifter
    1826            3 :     (:superlifter ctx)
    1827            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchUserById id))))))
    1828              : 
    1829              : 
    1830           14 : (s/def-superfetcher
    1831              :  FetchUserRankedinById
    1832              :  [id]
    1833            1 :  (fn [fetchers {:keys [repos]}]
    1834            4 :   (let [repo  (:user-rankedin-postgres-repo repos)
    1835            4 :         ids   (map :id fetchers)
    1836            4 :         all   (user-rankedin-query/get-users-rankedin-by-ids repo ids)
    1837            4 :         by-id (group-by-str :uuid all)]
    1838           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1839              : 
    1840              : 
    1841            4 : (defn user-rankedin-by-id-resolver
    1842              :  [ctx _args val]
    1843            9 :  (when-let [id (:userIdRankedin val)]
    1844            9 :    (s/with-superlifter
    1845            3 :     (:superlifter ctx)
    1846            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchUserRankedinById id))))))
    1847              : 
    1848              : 
    1849           14 : (s/def-superfetcher
    1850              :  FetchTeamById
    1851              :  [id]
    1852            1 :  (fn [fetchers {:keys [repos]}]
    1853            4 :   (let [repo  (:team-postgres-repo repos)
    1854            4 :         ids   (map :id fetchers)
    1855            4 :         all   (team-query/get-teams-by-ids repo ids)
    1856            4 :         by-id (group-by-str :uuid all)]
    1857           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1858              : 
    1859              : 
    1860            4 : (defn team-by-id-resolver
    1861              :  [ctx _args val]
    1862            9 :  (s/with-superlifter
    1863            3 :   (:superlifter ctx)
    1864            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchTeamById (:teamId val))))))
    1865              : 
    1866              : 
    1867              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1868           14 : (s/def-superfetcher
    1869              :  FetchAdvancementRulesByStage
    1870              :  [id]
    1871            1 :  (fn [fetchers {:keys [repos]}]
    1872            4 :   (let [repo  (:advancement-rule-postgres-repo repos)
    1873            4 :         ids   (map :id fetchers)
    1874            4 :         all   (advancement-rule-query/get-advancement-rules-by-stage-ids repo ids)
    1875            4 :         by-id (group-by-str :stage-id all)]
    1876           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1877              : 
    1878              : 
    1879            4 : (defn stage-advancement-rules-resolver
    1880              :  [ctx _args val]
    1881            9 :  (s/with-superlifter
    1882            3 :   (:superlifter ctx)
    1883            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchAdvancementRulesByStage (:uuid val))))))
    1884              : 
    1885              : 
    1886              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1887           14 : (s/def-superfetcher
    1888              :  FetchAdvancementsByRule
    1889              :  [id]
    1890            1 :  (fn [fetchers {:keys [repos]}]
    1891            4 :   (let [repo  (:advancement-postgres-repo repos)
    1892            4 :         ids   (map :id fetchers)
    1893            4 :         all   (advancement-query/get-advancements-by-rule-ids repo ids)
    1894            4 :         by-id (group-by-str :rule-id all)]
    1895           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    1896              : 
    1897              : 
    1898            4 : (defn rule-advancements-resolver
    1899              :  [ctx _args val]
    1900            9 :  (s/with-superlifter
    1901            3 :   (:superlifter ctx)
    1902            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchAdvancementsByRule (:uuid val))))))
    1903              : 
    1904              : 
    1905              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1906           14 : (s/def-superfetcher
    1907              :  FetchDrawById
    1908              :  [id]
    1909            1 :  (fn [fetchers {:keys [repos]}]
    1910            4 :   (let [repo  (:draw-postgres-repo repos)
    1911            4 :         ids   (map :id fetchers)
    1912            4 :         all   (draw-query/get-draws-by-ids repo ids)
    1913            4 :         by-id (group-by-str :uuid all)]
    1914           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1915              : 
    1916              : 
    1917              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1918           32 : (s/def-superfetcher
    1919              :  FetchGroupById
    1920              :  [id]
    1921            2 :  (fn [fetchers {:keys [repos]}]
    1922            8 :   (let [repo  (:group-postgres-repo repos)
    1923            8 :         ids   (map :id fetchers)
    1924            8 :         all   (group-query/get-groups-by-ids repo ids)
    1925            8 :         by-id (group-by-str :uuid all)]
    1926           30 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1927              : 
    1928              : 
    1929              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1930           14 : (s/def-superfetcher
    1931              :  FetchBracketById
    1932              :  [id]
    1933            1 :  (fn [fetchers {:keys [repos]}]
    1934            4 :   (let [repo  (:bracket-postgres-repo repos)
    1935            4 :         ids   (map :id fetchers)
    1936            4 :         all   (bracket-query/get-brackets-by-ids repo ids)
    1937            4 :         by-id (group-by-str :uuid all)]
    1938           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1939              : 
    1940              : 
    1941              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    1942           32 : (s/def-superfetcher
    1943              :  FetchBracketMatchById
    1944              :  [id]
    1945            2 :  (fn [fetchers {:keys [repos]}]
    1946            8 :   (let [repo  (:bracket-match-postgres-repo repos)
    1947            8 :         ids   (map :id fetchers)
    1948            8 :         all   (bracket-match-query/get-bracket-matches-by-ids repo ids)
    1949            8 :         by-id (group-by-str :uuid all)]
    1950           30 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    1951              : 
    1952              : 
    1953            4 : (defn rule-source-draw-resolver
    1954              :  [ctx _args val]
    1955            9 :  (when-let [id (:sourceDrawId val)]
    1956            9 :    (s/with-superlifter
    1957            3 :     (:superlifter ctx)
    1958            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchDrawById id))))))
    1959              : 
    1960              : 
    1961            4 : (defn rule-source-group-resolver
    1962              :  [ctx _args val]
    1963            9 :  (when-let [id (:sourceGroupId val)]
    1964            9 :    (s/with-superlifter
    1965            3 :     (:superlifter ctx)
    1966            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchGroupById id))))))
    1967              : 
    1968              : 
    1969            4 : (defn rule-source-bracket-resolver
    1970              :  [ctx _args val]
    1971            6 :  (when-let [id (:sourceBracketId val)]
    1972            0 :    (s/with-superlifter
    1973            0 :     (:superlifter ctx)
    1974            0 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketById id))))))
    1975              : 
    1976              : 
    1977            4 : (defn rule-source-bracket-match-resolver
    1978              :  [ctx _args val]
    1979            6 :  (when-let [id (:sourceBracketMatchId val)]
    1980            0 :    (s/with-superlifter
    1981            0 :     (:superlifter ctx)
    1982            0 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketMatchById id))))))
    1983              : 
    1984              : 
    1985            4 : (defn rule-target-draw-resolver
    1986              :  [ctx _args val]
    1987            9 :  (when-let [id (:targetDrawId val)]
    1988            9 :    (s/with-superlifter
    1989            3 :     (:superlifter ctx)
    1990            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchDrawById id))))))
    1991              : 
    1992              : 
    1993            4 : (defn rule-target-group-resolver
    1994              :  [ctx _args val]
    1995            6 :  (when-let [id (:targetGroupId val)]
    1996            0 :    (s/with-superlifter
    1997            0 :     (:superlifter ctx)
    1998            0 :     (sl/->lacinia-promise (s/enqueue! (->FetchGroupById id))))))
    1999              : 
    2000              : 
    2001            4 : (defn rule-target-bracket-match-resolver
    2002              :  [ctx _args val]
    2003            6 :  (when-let [id (:targetBracketMatchId val)]
    2004            0 :    (s/with-superlifter
    2005            0 :     (:superlifter ctx)
    2006            0 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketMatchById id))))))
    2007              : 
    2008              : 
    2009            4 : (defn rule-target-bracket-resolver
    2010              :  [ctx _args val]
    2011            6 :  (when-let [id (:targetBracketId val)]
    2012            0 :    (s/with-superlifter
    2013            0 :     (:superlifter ctx)
    2014            0 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketById id))))))
    2015              : 
    2016              : 
    2017            4 : (defn rule-target-assignments-resolver
    2018              :  [ctx _args val]
    2019            4 :  (let [repos (:repos ctx)
    2020            2 :        rule  (advancement-rule-query/get-advancement-rule
    2021            3 :               (:advancement-rule-postgres-repo repos)
    2022            3 :               (:uuid val))]
    2023            5 :    (if (nil? rule)
    2024            0 :      []
    2025            7 :      (mapv domain->graphql (advancement-common/rule-target-assignments repos rule)))))
    2026              : 
    2027              : 
    2028            4 : (defn target-assignment-source-group-resolver
    2029              :  [ctx _args val]
    2030            9 :  (when-let [id (:sourceGroupId val)]
    2031            9 :    (s/with-superlifter
    2032            3 :     (:superlifter ctx)
    2033            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchGroupById id))))))
    2034              : 
    2035              : 
    2036            4 : (defn target-assignment-bracket-match-resolver
    2037              :  [ctx _args val]
    2038            9 :  (when-let [id (:bracketMatchId val)]
    2039            9 :    (s/with-superlifter
    2040            3 :     (:superlifter ctx)
    2041            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketMatchById id))))))
    2042              : 
    2043              : 
    2044            4 : (defn target-assignment-group-resolver
    2045              :  [ctx _args val]
    2046            9 :  (when-let [id (:groupId val)]
    2047            9 :    (s/with-superlifter
    2048            3 :     (:superlifter ctx)
    2049            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchGroupById id))))))
    2050              : 
    2051              : 
    2052            4 : (defn advancement-rule-resolver
    2053              :  [ctx args _val]
    2054            7 :  (let [repo (get-in ctx [:repos :advancement-rule-postgres-repo])
    2055            3 :        id   (:id args)]
    2056            1 :    (->
    2057            4 :      (advancement-rule-query/get-advancement-rule repo id)
    2058            1 :      domain->graphql)))
    2059              : 
    2060              : 
    2061            4 : (defn advancement-rules-resolver
    2062              :  [ctx args _val]
    2063            2 :  (either->resolve
    2064           10 :   (c/mlet [pagination (parse-pagination args)]
    2065            7 :     (let [repo    (get-in ctx [:repos :advancement-rule-postgres-repo])
    2066            8 :           filters (or (:filter args) {})
    2067            5 :           result  (advancement-rule-query/search-advancement-rules repo filters pagination)]
    2068            2 :       (either/right
    2069            1 :        (->
    2070            1 :          result
    2071            8 :          (update :items #(mapv domain->graphql %))
    2072            1 :          domain->graphql))))))
    2073              : 
    2074              : 
    2075            4 : (defn advancement-resolver
    2076              :  [ctx args _val]
    2077            7 :  (let [repo (get-in ctx [:repos :advancement-postgres-repo])
    2078            3 :        id   (:id args)]
    2079            1 :    (->
    2080            4 :      (advancement-query/get-advancement repo id)
    2081            1 :      domain->graphql)))
    2082              : 
    2083              : 
    2084            4 : (defn advancements-resolver
    2085              :  [ctx args _val]
    2086            2 :  (either->resolve
    2087           10 :   (c/mlet [pagination (parse-pagination args)]
    2088            7 :     (let [repo    (get-in ctx [:repos :advancement-postgres-repo])
    2089            8 :           filters (or (:filter args) {})
    2090            5 :           result  (advancement-query/search-advancements repo filters pagination)]
    2091            2 :       (either/right
    2092            1 :        (->
    2093            1 :          result
    2094            8 :          (update :items #(mapv domain->graphql %))
    2095            1 :          domain->graphql))))))
    2096              : 
    2097              : 
    2098              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2099           32 : (s/def-superfetcher
    2100              :  FetchGroupParticipantsByGroup
    2101              :  [id]
    2102            2 :  (fn [fetchers {:keys [repos]}]
    2103            8 :   (let [repo  (:group-participant-postgres-repo repos)
    2104            8 :         ids   (map :id fetchers)
    2105            8 :         all   (group-participant-query/get-group-participants-by-group-ids repo ids)
    2106            8 :         by-id (group-by-str :group-id all)]
    2107           28 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    2108              : 
    2109              : 
    2110            4 : (defn group-participants-resolver
    2111              :  [ctx _args val]
    2112            9 :  (s/with-superlifter
    2113            3 :   (:superlifter ctx)
    2114            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchGroupParticipantsByGroup (:uuid val))))))
    2115              : 
    2116              : 
    2117              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2118           14 : (s/def-superfetcher
    2119              :  FetchSeriesByGroup
    2120              :  [id]
    2121            1 :  (fn [fetchers {:keys [repos]}]
    2122            4 :   (let [repo  (:series-postgres-repo repos)
    2123            4 :         ids   (map :id fetchers)
    2124            4 :         all   (series-query/get-series-by-group-ids repo ids)
    2125            4 :         by-id (group-by-str :group-id all)]
    2126           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    2127              : 
    2128              : 
    2129            4 : (defn group-series-resolver
    2130              :  [ctx _args val]
    2131            9 :  (s/with-superlifter
    2132            3 :   (:superlifter ctx)
    2133            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchSeriesByGroup (:uuid val))))))
    2134              : 
    2135              : 
    2136              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2137           14 : (s/def-superfetcher
    2138              :  FetchMatchesBySeries
    2139              :  [id]
    2140            1 :  (fn [fetchers {:keys [repos]}]
    2141            4 :   (let [repo  (:match-postgres-repo repos)
    2142            4 :         ids   (map :id fetchers)
    2143            4 :         all   (match-query/get-matches-by-series-ids repo ids)
    2144            4 :         by-id (group-by-str :series-id all)]
    2145           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    2146              : 
    2147              : 
    2148            4 : (defn series-matches-resolver
    2149              :  [ctx _args val]
    2150            9 :  (s/with-superlifter
    2151            3 :   (:superlifter ctx)
    2152            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchesBySeries (:uuid val))))))
    2153              : 
    2154              : 
    2155              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2156           14 : (s/def-superfetcher
    2157              :  FetchMatchResultByMatch
    2158              :  [id]
    2159            1 :  (fn [fetchers {:keys [repos]}]
    2160            4 :   (let [repo  (:match-result-postgres-repo repos)
    2161            4 :         ids   (map :id fetchers)
    2162            4 :         all   (match-result-query/get-match-results-by-match-ids repo ids)
    2163            4 :         by-id (group-by-str :match-id all)]
    2164           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    2165              : 
    2166              : 
    2167            4 : (defn match-result-resolver
    2168              :  [ctx _args val]
    2169            9 :  (s/with-superlifter
    2170            3 :   (:superlifter ctx)
    2171            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchResultByMatch (:uuid val))))))
    2172              : 
    2173              : 
    2174              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2175           14 : (s/def-superfetcher
    2176              :  FetchMatchesByGroup
    2177              :  [id]
    2178            1 :  (fn [fetchers {:keys [repos]}]
    2179            4 :   (let [repo  (:match-postgres-repo repos)
    2180            4 :         ids   (map :id fetchers)
    2181            4 :         all   (match-query/get-matches-by-group-ids repo ids)
    2182            4 :         by-id (group-by-str :group-id all)]
    2183           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    2184              : 
    2185              : 
    2186            4 : (defn group-matches-resolver
    2187              :  [ctx _args val]
    2188            9 :  (s/with-superlifter
    2189            3 :   (:superlifter ctx)
    2190            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchesByGroup (:uuid val))))))
    2191              : 
    2192              : 
    2193              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2194           14 : (s/def-superfetcher
    2195              :  FetchMatchSegmentsByMatch
    2196              :  [id]
    2197            1 :  (fn [fetchers {:keys [repos]}]
    2198            4 :   (let [repo  (:match-segment-postgres-repo repos)
    2199            4 :         ids   (map :id fetchers)
    2200            4 :         all   (match-segment-query/get-match-segments-by-match-ids repo ids)
    2201            4 :         by-id (group-by-str :match-id all)]
    2202           14 :     (mapv #(mapv domain->graphql (get-str-key by-id (:id %) [])) fetchers))))
    2203              : 
    2204              : 
    2205            4 : (defn match-segments-resolver
    2206              :  [ctx _args val]
    2207            9 :  (s/with-superlifter
    2208            3 :   (:superlifter ctx)
    2209            9 :   (sl/->lacinia-promise (s/enqueue! (->FetchMatchSegmentsByMatch (:uuid val))))))
    2210              : 
    2211              : 
    2212              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2213           14 : (s/def-superfetcher
    2214              :  FetchEventById
    2215              :  [id]
    2216            1 :  (fn [fetchers {:keys [repos]}]
    2217            4 :   (let [repo  (:event-postgres-repo repos)
    2218            4 :         ids   (map :id fetchers)
    2219            4 :         all   (event-query/get-events-by-ids repo ids)
    2220            4 :         by-id (group-by-str :uuid all)]
    2221           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    2222              : 
    2223              : 
    2224              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2225           14 : (s/def-superfetcher
    2226              :  FetchEventByStageId
    2227              :  [id]
    2228            1 :  (fn [fetchers {:keys [repos]}]
    2229            4 :   (let [repo  (:event-postgres-repo repos)
    2230            4 :         ids   (map :id fetchers)
    2231            4 :         all   (event-query/get-events-by-stage-ids repo ids)
    2232            4 :         by-id (group-by-str :stage-id all)]
    2233           17 :     (mapv #(domain->graphql (:event (first (get-str-key by-id (:id %) [])))) fetchers))))
    2234              : 
    2235              : 
    2236            4 : (defn match-event-resolver
    2237              :  "Resolves the owning event. Prefers the denormalized event_id, but matches created
    2238              :   through bracket/group draws may have a null event_id, so it falls back to the
    2239              :   stage -> class -> event chain."
    2240              :  [ctx _args val]
    2241           11 :  (let [event-id (or (:eventId val) (:event-id val))
    2242           10 :        stage-id (or (:stageId val) (:stage-id val))]
    2243            3 :    (cond event-id
    2244            9 :          (s/with-superlifter
    2245            3 :           (:superlifter ctx)
    2246            7 :           (sl/->lacinia-promise (s/enqueue! (->FetchEventById event-id))))
    2247              : 
    2248            1 :          stage-id
    2249            9 :          (s/with-superlifter
    2250            3 :           (:superlifter ctx)
    2251            7 :           (sl/->lacinia-promise (s/enqueue! (->FetchEventByStageId stage-id)))))))
    2252              : 
    2253              : 
    2254            4 : (defn match-home-participant-resolver
    2255              :  [ctx _args val]
    2256           13 :  (when-let [id (or (:homeParticipantId val) (:home-participant-id val))]
    2257            9 :    (s/with-superlifter
    2258            3 :     (:superlifter ctx)
    2259            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchParticipantById id))))))
    2260              : 
    2261              : 
    2262            4 : (defn match-away-participant-resolver
    2263              :  [ctx _args val]
    2264           13 :  (when-let [id (or (:awayParticipantId val) (:away-participant-id val))]
    2265            9 :    (s/with-superlifter
    2266            3 :     (:superlifter ctx)
    2267            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchParticipantById id))))))
    2268              : 
    2269              : 
    2270            4 : (defn match-group-resolver
    2271              :  [ctx _args val]
    2272           13 :  (when-let [id (or (:groupId val) (:group-id val))]
    2273            9 :    (s/with-superlifter
    2274            3 :     (:superlifter ctx)
    2275            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchGroupById id))))))
    2276              : 
    2277              : 
    2278            4 : (defn match-bracket-match-resolver
    2279              :  [ctx _args val]
    2280           16 :  (when-let [id (or (:bracketMatchId val) (:bracket-match-id val))]
    2281            9 :    (s/with-superlifter
    2282            3 :     (:superlifter ctx)
    2283            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketMatchById id))))))
    2284              : 
    2285              : 
    2286              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2287           14 : (s/def-superfetcher
    2288              :  FetchClassByStageId
    2289              :  [id]
    2290            1 :  (fn [fetchers {:keys [repos]}]
    2291            4 :   (let [repo  (:class-postgres-repo repos)
    2292            4 :         ids   (map :id fetchers)
    2293            4 :         all   (class-query/get-classes-by-stage-ids repo ids)
    2294            4 :         by-id (group-by-str :stage-id all)]
    2295           17 :     (mapv #(domain->graphql (:class (first (get-str-key by-id (:id %) [])))) fetchers))))
    2296              : 
    2297              : 
    2298            4 : (defn match-class-resolver
    2299              :  [ctx _args val]
    2300           13 :  (when-let [id (or (:stageId val) (:stage-id val))]
    2301            9 :    (s/with-superlifter
    2302            3 :     (:superlifter ctx)
    2303            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchClassByStageId id))))))
    2304              : 
    2305              : 
    2306            4 : (defn match-stage-resolver
    2307              :  [ctx _args val]
    2308            0 :  (when-let [id (or (:stageId val) (:stage-id val))]
    2309            0 :    (some->
    2310            0 :      (stage-query/get-stage (get-in ctx [:repos :stage-postgres-repo]) id)
    2311            0 :      domain->graphql)))
    2312              : 
    2313              : 
    2314            4 : (defn match-draw-resolver
    2315              :  [ctx _args val]
    2316            0 :  (let [repos    (:repos ctx)
    2317            0 :        group-id (or (:groupId val) (:group-id val))
    2318            0 :        bm-id    (or (:bracketMatchId val) (:bracket-match-id val))
    2319            0 :        draw-id  (if group-id
    2320            0 :                   (some->
    2321            0 :                     (group-query/get-group (:group-postgres-repo repos) group-id)
    2322              :                     :draw-id)
    2323            0 :                   (when bm-id
    2324            0 :                     (some->
    2325            0 :                       (bracket-match-query/get-bracket-match
    2326            0 :                        (:bracket-match-postgres-repo repos)
    2327            0 :                        bm-id)
    2328              :                       :bracket-round-id
    2329            0 :                       (->>
    2330            0 :                         (bracket-round-query/get-bracket-round
    2331            0 :                          (:bracket-round-postgres-repo repos)))
    2332              :                       :bracket-id
    2333            0 :                       (->>
    2334            0 :                         (bracket-query/get-bracket (:bracket-postgres-repo repos)))
    2335              :                       :draw-id)))]
    2336            0 :    (when draw-id
    2337            0 :      (some->
    2338            0 :        (draw-query/get-draw (:draw-postgres-repo repos) draw-id)
    2339            0 :        domain->graphql))))
    2340              : 
    2341              : 
    2342              : ;; Field must be named `id` — urania's -identity is hardcoded to (:id this)
    2343           14 : (s/def-superfetcher
    2344              :  FetchBracketRoundById
    2345              :  [id]
    2346            1 :  (fn [fetchers {:keys [repos]}]
    2347            4 :   (let [repo  (:bracket-round-postgres-repo repos)
    2348            4 :         ids   (map :id fetchers)
    2349            4 :         all   (bracket-round-query/get-bracket-rounds-by-ids repo ids)
    2350            4 :         by-id (group-by-str :uuid all)]
    2351           15 :     (mapv #(domain->graphql (first (get-str-key by-id (:id %) []))) fetchers))))
    2352              : 
    2353              : 
    2354            4 : (defn bracket-match-bracket-round-resolver
    2355              :  [ctx _args val]
    2356           13 :  (when-let [id (or (:bracketRoundId val) (:bracket-round-id val))]
    2357            9 :    (s/with-superlifter
    2358            3 :     (:superlifter ctx)
    2359            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketRoundById id))))))
    2360              : 
    2361              : 
    2362            4 : (defn bracket-round-bracket-resolver
    2363              :  [ctx _args val]
    2364           13 :  (when-let [id (or (:bracketId val) (:bracket-id val))]
    2365            9 :    (s/with-superlifter
    2366            3 :     (:superlifter ctx)
    2367            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchBracketById id))))))
    2368              : 
    2369              : 
    2370            4 : (defn bracket-draw-resolver
    2371              :  [ctx _args val]
    2372           13 :  (when-let [id (or (:drawId val) (:draw-id val))]
    2373            9 :    (s/with-superlifter
    2374            3 :     (:superlifter ctx)
    2375            7 :     (sl/->lacinia-promise (s/enqueue! (->FetchDrawById id))))))
    2376              : 
    2377              : 
    2378            4 : (defn resolver-map
    2379              :  []
    2380          632 :  {:resolve/account account-resolver
    2381           12 :   :resolve/private-telegram-id (private-field-resolver :telegramId)
    2382            4 :   :resolve/private-name-confirmed-at private-name-confirmed-at-resolver
    2383           12 :   :resolve/private-settings (private-field-resolver :settings)
    2384            4 :   :resolve/host host-resolver
    2385           12 :   :resolve/private-created-by (private-field-resolver :createdBy)
    2386           12 :   :resolve/private-status (private-field-resolver :status)
    2387           12 :   :resolve/private-registered-at (private-field-resolver :registeredAt)
    2388           12 :   :resolve/private-confirmed-at (private-field-resolver :confirmedAt)
    2389           12 :   :resolve/private-checked-in-at (private-field-resolver :checkedInAt)
    2390           12 :   :resolve/private-extra (private-field-resolver :extra)
    2391           12 :   :resolve/private-roles (private-list-field-resolver :roles)
    2392           12 :   :resolve/private-attendance-confirmed (private-field-resolver :attendanceConfirmed)
    2393           12 :   :resolve/private-payment-status (private-field-resolver :paymentStatus)
    2394           12 :   :resolve/private-payment-amount (private-field-resolver :paymentAmount)
    2395           12 :   :resolve/private-payment-currency (private-field-resolver :paymentCurrency)
    2396           12 :   :resolve/private-paid-at (private-field-resolver :paidAt)
    2397           12 :   :resolve/private-payment-marked-by (private-field-resolver :paymentMarkedBy)
    2398           12 :   :resolve/private-automatic-event-creation (private-field-resolver :automaticEventCreation)
    2399           12 :   :resolve/private-automatic-event-creation-delay-minutes (private-field-resolver
    2400              :                                                            :automaticEventCreationDelayMinutes)
    2401            4 :   :resolve/account-roles account-roles-resolver
    2402            4 :   :resolve/account-name-locks account-name-locks-resolver
    2403              :   :resolve/user-telegram-match-notifications-enabled
    2404            4 :   user-telegram-match-notifications-enabled-resolver
    2405            4 :   :resolve/user-name-localized user-name-localized-resolver
    2406            4 :   :resolve/user-notification-settings user-notification-settings-resolver
    2407            4 :   :resolve/tournament-tiers tournament-tiers-resolver
    2408            4 :   :resolve/my-tournament-subscriptions my-tournament-subscriptions-resolver
    2409            4 :   :resolve/subscribe-tournaments subscribe-tournaments-resolver
    2410            4 :   :resolve/unsubscribe-tournaments unsubscribe-tournaments-resolver
    2411            4 :   :resolve/my-updates my-updates-resolver
    2412            4 :   :resolve/unread-updates-count unread-updates-count-resolver
    2413            4 :   :resolve/mark-updates-read mark-updates-read-resolver
    2414            4 :   :resolve/set-updates-read set-updates-read-resolver
    2415            4 :   :resolve/dev-test-notifications dev-test-notifications-resolver
    2416            4 :   :resolve/user user-resolver
    2417            4 :   :resolve/users users-resolver
    2418            4 :   :resolve/reference-data reference-data-resolver
    2419            4 :   :resolve/search-users search-users-resolver
    2420            4 :   :resolve/search-users-for-event search-users-for-event-resolver
    2421            4 :   :resolve/search-users-for-template search-users-for-template-resolver
    2422            4 :   :resolve/club club-resolver
    2423            4 :   :resolve/clubs clubs-resolver
    2424            4 :   :resolve/esf-tournaments esf-tournaments-resolver
    2425            4 :   :resolve/esf-tournament esf-tournament-resolver
    2426            4 :   :resolve/esf-ranking esf-ranking-resolver
    2427            4 :   :resolve/fsu-tournaments fsu-tournaments-resolver
    2428            4 :   :resolve/fsu-rating fsu-rating-resolver
    2429            4 :   :resolve/source-synced-at source-synced-at-resolver
    2430            4 :   :resolve/event-source-synced-at event-source-synced-at-resolver
    2431            4 :   :resolve/psa-seasons psa-seasons-resolver
    2432            4 :   :resolve/psa-tournaments psa-tournaments-resolver
    2433            4 :   :resolve/psa-tournament psa-tournament-resolver
    2434            4 :   :resolve/psa-tournament-videos psa-tournament-videos-resolver
    2435            4 :   :resolve/psa-ranking psa-ranking-resolver
    2436            4 :   :resolve/my-psa-follows my-psa-follows-resolver
    2437            4 :   :resolve/my-player-follows my-player-follows-resolver
    2438            4 :   :resolve/player-profile player-profile-resolver
    2439            4 :   :resolve/search-players search-players-resolver
    2440            4 :   :resolve/global-search global-search-resolver
    2441            4 :   :resolve/club-courts club-courts-resolver
    2442            4 :   :resolve/search-clubs search-clubs-resolver
    2443            4 :   :resolve/class class-resolver
    2444            4 :   :resolve/classes classes-resolver
    2445            4 :   :resolve/template template-resolver
    2446            4 :   :resolve/template-images template-images-resolver
    2447            4 :   :resolve/template-cover-image template-cover-image-resolver
    2448            4 :   :resolve/template-automation template-automation-resolver
    2449            4 :   :resolve/template-telegram-links template-telegram-links-resolver
    2450            4 :   :resolve/my-telegram-links my-telegram-links-resolver
    2451            4 :   :resolve/my-unlinked-telegram-resources my-unlinked-telegram-resources-resolver
    2452            4 :   :resolve/search-templates search-templates-resolver
    2453            4 :   :resolve/user-templates user-templates-resolver
    2454            4 :   :resolve/user-participating-templates user-participating-templates-resolver
    2455            4 :   :resolve/template-club template-club-resolver
    2456            4 :   :resolve/template-club-id template-club-id-resolver
    2457            4 :   :resolve/template-clubs template-clubs-resolver
    2458            4 :   :resolve/template-classes template-class-templates-resolver
    2459            4 :   :resolve/template-participants template-participants-resolver
    2460            4 :   :resolve/class-template-participants class-template-participants-resolver
    2461            4 :   :resolve/class-templates class-templates-resolver
    2462            4 :   :resolve/event event-resolver
    2463            4 :   :resolve/event-images event-images-resolver
    2464            4 :   :resolve/event-cover-image event-cover-image-resolver
    2465            4 :   :resolve/events events-resolver
    2466            4 :   :resolve/public-events public-events-resolver
    2467            4 :   :resolve/event-club event-club-resolver
    2468            4 :   :resolve/event-club-id event-club-id-resolver
    2469            4 :   :resolve/event-clubs event-clubs-resolver
    2470            4 :   :resolve/event-user-place event-user-place-resolver
    2471            4 :   :resolve/event-user-places event-user-places-resolver
    2472            4 :   :resolve/event-telegram-links event-telegram-links-resolver
    2473            4 :   :resolve/event-stage1-draws-revision event-stage1-draws-revision-resolver
    2474            4 :   :resolve/event-source-url event-source-url-resolver
    2475            4 :   :resolve/event-psa-id event-psa-id-resolver
    2476            4 :   :resolve/event-telegram-chat-messages event-telegram-chat-messages-resolver
    2477            4 :   :resolve/template-telegram-chat-messages template-telegram-chat-messages-resolver
    2478            4 :   :resolve/user-events user-events-resolver
    2479            4 :   :resolve/user-participating-events user-participating-events-resolver
    2480            4 :   :resolve/stage stage-resolver
    2481            4 :   :resolve/stages stages-resolver
    2482            4 :   :resolve/event-participants event-participants-resolver
    2483            4 :   :resolve/event-classes event-classes-resolver
    2484            4 :   :resolve/event-template event-template-resolver
    2485            4 :   :resolve/class-participants class-participants-resolver
    2486            4 :   :resolve/class-stages stages-by-class-resolver
    2487            4 :   :resolve/stage-draws draws-by-stage-resolver
    2488            4 :   :resolve/stage-advancement-rules stage-advancement-rules-resolver
    2489            4 :   :resolve/rule-advancements rule-advancements-resolver
    2490            4 :   :resolve/advancement-rule advancement-rule-resolver
    2491            4 :   :resolve/advancement-rules advancement-rules-resolver
    2492            4 :   :resolve/advancement advancement-resolver
    2493            4 :   :resolve/advancements advancements-resolver
    2494            4 :   :resolve/draw-groups groups-by-draw-resolver
    2495            4 :   :resolve/draw-brackets brackets-by-draw-resolver
    2496            4 :   :resolve/bracket-rounds bracket-rounds-by-bracket-resolver
    2497            4 :   :resolve/bracket-matches bracket-matches-by-round-resolver
    2498            4 :   :resolve/bracket-match-slots bracket-match-slots-by-match-resolver
    2499            4 :   :resolve/bracket-match-series bracket-match-series-resolver
    2500            4 :   :resolve/bracket-match-result bracket-match-result-resolver
    2501            4 :   :resolve/bracket-match-segments bracket-match-segments-resolver
    2502            4 :   :resolve/bracket-match-match bracket-match-match-resolver
    2503            4 :   :resolve/participant participant-resolver
    2504            4 :   :resolve/group-participants group-participants-resolver
    2505            4 :   :resolve/group-series group-series-resolver
    2506            4 :   :resolve/series-matches series-matches-resolver
    2507            4 :   :resolve/match-result match-result-resolver
    2508            4 :   :resolve/group-matches group-matches-resolver
    2509            4 :   :resolve/match-segments match-segments-resolver
    2510            4 :   :resolve/user-matches user-matches-resolver
    2511            4 :   :resolve/match match-resolver
    2512            4 :   :resolve/match-event match-event-resolver
    2513            4 :   :resolve/match-home-participant match-home-participant-resolver
    2514            4 :   :resolve/match-away-participant match-away-participant-resolver
    2515            4 :   :resolve/match-group match-group-resolver
    2516            4 :   :resolve/match-bracket-match match-bracket-match-resolver
    2517            4 :   :resolve/match-class match-class-resolver
    2518            4 :   :resolve/match-stage match-stage-resolver
    2519            4 :   :resolve/match-draw match-draw-resolver
    2520            4 :   :resolve/bracket-match-bracket-round bracket-match-bracket-round-resolver
    2521            4 :   :resolve/bracket-round-bracket bracket-round-bracket-resolver
    2522            4 :   :resolve/bracket-draw bracket-draw-resolver
    2523            4 :   :resolve/user-by-id user-by-id-resolver
    2524            4 :   :resolve/user-rankedin-by-id user-rankedin-by-id-resolver
    2525            4 :   :resolve/team team-by-id-resolver
    2526            4 :   :resolve/rule-source-draw rule-source-draw-resolver
    2527            4 :   :resolve/rule-source-group rule-source-group-resolver
    2528            4 :   :resolve/rule-source-bracket rule-source-bracket-resolver
    2529            4 :   :resolve/rule-source-bracket-match rule-source-bracket-match-resolver
    2530            4 :   :resolve/rule-target-draw rule-target-draw-resolver
    2531            4 :   :resolve/rule-target-group rule-target-group-resolver
    2532            4 :   :resolve/rule-target-bracket-match rule-target-bracket-match-resolver
    2533            4 :   :resolve/rule-target-bracket rule-target-bracket-resolver
    2534            4 :   :resolve/rule-target-assignments rule-target-assignments-resolver
    2535            4 :   :resolve/target-assignment-source-group target-assignment-source-group-resolver
    2536            4 :   :resolve/target-assignment-bracket-match target-assignment-bracket-match-resolver
    2537            4 :   :resolve/target-assignment-group target-assignment-group-resolver})
        

Generated by: LCOV version 2.0-1