<commit_before>{-# LANGUAGE QuasiQuotes #-}
module TournamentSummaryHtml where

import Law
import Formatting
import Data.List (sortBy)
import Data.Foldable (foldMap)
import Data.Ord (comparing)
import Data.Time.Calendar
import Data.List.Split (chunksOf)
import Tournament
import Text.Hamlet (Html, shamlet)
import Control.Lens
import Data.Map (Map)
import qualified Data.Map as Map
import Text.Blaze.Html.Renderer.String (renderHtml)
import Text.Blaze.Html (preEscapedToHtml)

tournamentColumns = 2

ratingsHtml :: Day -> Map String (Day,Law) -> String
ratingsHtml day laws = renderHtml [shamlet|
$doctype 5
<html>
  <head>
    <meta charset=utf-8>
    <title>#{title}
    <link rel=stylesheet href=ratings.css>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js">
    <script language=javascript src=flot/jquery.flot.js>
    <script language=javascript src=jquery.tablesorter.min.js>
    <script language=javascript>#{preEscapedToHtml $ graphScript $ map rowLaw rows}
    <script language=javascript>$(document).ready(function(){ $("#players-table").tablesorter();});
  <body>
    <h1>#{title}
    <table #players-table>
      <thead>
       <tr>
         <th>Player
         <th>μ
         <th>σ
         <th>Metric
         <th>Last played
         <th>Graph
      <tbody>
        $forall (i,name,lastday,law) <- rows
          <tr :odd i:.alt>
            <td .str>#{name}
            <td .num>#{showRound $ lawMean law}
            <td .num>#{showRound $ lawStddev law}
            <td .num>#{showRound $ lawScore law}
            <td .str>
              $if day == lastday
                <i>today
              $else
                #{formatShortDay day}
            <td>
              <div .bargraph #graph#{i}>
  |]
  where
  title       = "Player List - " ++ formatLongDay day
  byScore     = flip (comparing (lawScore . snd . snd))
  rows        = imap mkRow $ sortBy byScore $ Map.toList laws<commit_msg>Print correct day in Last Played column<commit_after>{-# LANGUAGE QuasiQuotes #-}
module TournamentSummaryHtml where

import Law
import Formatting
import Data.List (sortBy)
import Data.Foldable (foldMap)
import Data.Ord (comparing)
import Data.Time.Calendar
import Data.List.Split (chunksOf)
import Tournament
import Text.Hamlet (Html, shamlet)
import Control.Lens
import Data.Map (Map)
import qualified Data.Map as Map
import Text.Blaze.Html.Renderer.String (renderHtml)
import Text.Blaze.Html (preEscapedToHtml)

tournamentColumns = 2

ratingsHtml :: Day -> Map String (Day,Law) -> String
ratingsHtml day laws = renderHtml [shamlet|
$doctype 5
<html>
  <head>
    <meta charset=utf-8>
    <title>#{title}
    <link rel=stylesheet href=ratings.css>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js">
    <script language=javascript src=flot/jquery.flot.js>
    <script language=javascript src=jquery.tablesorter.min.js>
    <script language=javascript>#{preEscapedToHtml $ graphScript $ map rowLaw rows}
    <script language=javascript>$(document).ready(function(){ $("#players-table").tablesorter();});
  <body>
    <h1>#{title}
    <table #players-table>
      <thead>
       <tr>
         <th>Player
         <th>μ
         <th>σ
         <th>Metric
         <th>Last played
         <th>Graph
      <tbody>
        $forall (i,name,lastday,law) <- rows
          <tr :odd i:.alt>
            <td .str>#{name}
            <td .num>#{showRound $ lawMean law}
            <td .num>#{showRound $ lawStddev law}
            <td .num>#{showRound $ lawScore law}
            <td .str>
              $if day == lastday
                <i>today
              $else
                #{formatShortDay lastday}
            <td>
              <div .bargraph #graph#{i}>
  |]
  where
  title       = "Player List - " ++ formatLongDay day
  byScore     = flip (comparing (lawScore . snd . snd))
  rows        = imap mkRow $ sortBy byScore $ Map.toList laws
{'fraction_non_alphanumeric': 0.12710566615620214, 'fraction_numerical': 0.0030627871362940277, 'mean_word_length': 2.585544373284538, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 69, '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': '1170823', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1264, 'n_words': 309}