<commit_before>(ns rpi-challenger.views
  (:use net.cgrand.enlive-html)
  (:require [rpi-challenger.core.challenges :as c]
            [rpi-challenger.core.participant :as p]
            [rpi-challenger.core.strike :as s]
            [clj-time.core :as time])
  (:import [org.joda.time LocalDateTime]))

; layout

(deftemplate layout "public/layout.html"
  [{:keys [title main]}]
  [:title ] (content title)
  [:h2 ] (content title)
  [:#main ] (substitute main))


; participants list

(def *participants-row [:#participants [:tr (nth-of-type 2)]])
(def *participant-link [[:a (nth-of-type 1)]])
(def *participant-score [[:td (nth-of-type 2)]])
(def *participant-score-history [[:div.score-history ]])

(defsnippet participants-row "public/tournament.html" *participants-row
  [participant]
  *participant-link (do->
                      (content (:name participant))
                      (set-attr :href (str "/participant-" (:id participant))))
  *participant-score (content (str (:score participant)))
  *participant-score-history (set-attr :data-url (str "/participant-" (:id participant) "/score-history")))

(defsnippet tournament-overview "public/tournament.html" [:body :> any-node]
  [participants]
  *participants-row (content (map #(participants-row %) participants)))
<commit_msg>Sort the participants by score<commit_after>(ns rpi-challenger.views
  (:use net.cgrand.enlive-html)
  (:require [rpi-challenger.core.challenges :as c]
            [rpi-challenger.core.participant :as p]
            [rpi-challenger.core.strike :as s]
            [clj-time.core :as time])
  (:import [org.joda.time LocalDateTime]))

; layout

(deftemplate layout "public/layout.html"
  [{:keys [title main]}]
  [:title ] (content title)
  [:h2 ] (content title)
  [:#main ] (substitute main))


; participants list

(def *participants-row [:#participants [:tr (nth-of-type 2)]])
(def *participant-link [[:a (nth-of-type 1)]])
(def *participant-score [[:td (nth-of-type 2)]])
(def *participant-score-history [[:div.score-history ]])

(defsnippet participants-row "public/tournament.html" *participants-row
  [participant]
  *participant-link (do->
                      (content (:name participant))
                      (set-attr :href (str "/participant-" (:id participant))))
  *participant-score (content (str (:score participant)))
  *participant-score-history (set-attr :data-url (str "/participant-" (:id participant) "/score-history")))

(defsnippet tournament-overview "public/tournament.html" [:body :> any-node]
  [participants]
  *participants-row (content (map #(participants-row %) (sort-by :score > participants))))

{'fraction_non_alphanumeric': 0.17022086824067023, 'fraction_numerical': 0.0030464584920030465, 'mean_word_length': 3.699463327370304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3194188', 'n_tokens_mistral': 954, 'n_tokens_neox': 871, 'n_words': 200}