Extract common parameters when showing results
This commit is contained in:
parent
b8b1eefa6b
commit
132b0f7ad9
@ -651,11 +651,14 @@ resultTable (Entity submissionId submission) = do
|
||||
id
|
||||
(submissionChallenge submission)
|
||||
|
||||
let (commonParams', strippedTableEntries) = extractCommonParams tableEntries
|
||||
let commonParams = map (\(Entity _ p) -> (parameterName p, OneThing $ parameterValue p)) commonParams'
|
||||
|
||||
let paramNames =
|
||||
nub
|
||||
$ map (parameterName . entityVal)
|
||||
$ concat
|
||||
$ map tableEntryParams tableEntries
|
||||
$ map tableEntryParams strippedTableEntries
|
||||
|
||||
let maximumNumberOfColumns = 10
|
||||
|
||||
|
@ -37,6 +37,8 @@ import Data.Proxy as DPR
|
||||
import Control.Lens hiding ((.=), (^.))
|
||||
import Data.HashMap.Strict.InsOrd (fromList)
|
||||
|
||||
import qualified Data.Set as S
|
||||
|
||||
data TestReference = TestReference Text Text
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
@ -77,6 +79,21 @@ data LeaderboardEntry = LeaderboardEntry {
|
||||
leaderboardTeam :: Maybe (Entity Team)
|
||||
}
|
||||
|
||||
-- | Finds parameters shared by all entries (including values) and removes
|
||||
-- them from the entries
|
||||
extractCommonParams :: [TableEntry] -> ([Entity Parameter], [TableEntry])
|
||||
extractCommonParams [] = ([], [])
|
||||
extractCommonParams entries@(firstEntry:_) = (commonParams, map removeParams entries)
|
||||
where commonParams = filter (\p -> paramToNameVal p `S.member` commonNameVals) $ tableEntryParams firstEntry
|
||||
commonNameVals =
|
||||
DL.foldl intersection hS tS
|
||||
(hS:tS) = map (S.fromList
|
||||
. map paramToNameVal
|
||||
. tableEntryParams) entries
|
||||
paramToNameVal (Entity _ p) = (parameterName p, parameterValue p)
|
||||
removeParams e
|
||||
= e { tableEntryParams = filter (\p -> paramToNameVal p `S.notMember` commonNameVals) $ tableEntryParams e }
|
||||
|
||||
data TableEntry = TableEntry {
|
||||
tableEntrySubmission :: Entity Submission,
|
||||
tableEntryVariant :: Entity Variant,
|
||||
|
@ -2,4 +2,7 @@
|
||||
$if null tableEntries
|
||||
<p>No results available. The submission is probably broken.
|
||||
$else
|
||||
^{Table.buildBootstrap (variantTable paramNames tests) tableEntries}
|
||||
^{Table.buildBootstrap (variantTable paramNames tests) strippedTableEntries}
|
||||
|
||||
$if not (null commonParams)
|
||||
^{Table.buildBootstrap paramsTable $ commonParams}
|
||||
|
Loading…
Reference in New Issue
Block a user