module Web.View.PatternPerformance.Index where
import Web.View.Prelude
data IndexView = IndexView
{ records :: ![PatternPerformanceRecord]
, hubs :: ![Hub]
}
instance View IndexView where
html IndexView { .. } = [hsx|
Pattern Performance
{forM_ hubs \h -> [hsx|
|]}
| Rank |
Pattern |
Adoptions |
Positive / Total |
Positive Rate |
Mean Value |
{forM_ records renderRow}
|]
where
renderRow r =
let rate = if r.totalOutcomeCount > 0
then fromIntegral r.positiveOutcomeCount / fromIntegral r.totalOutcomeCount :: Double
else 0.0
rankLabel = maybe "-" show r.outcomeRank
in [hsx|
| {rankLabel} |
{show r.widgetPatternId}
|
{show r.adoptionCount} |
{show r.positiveOutcomeCount}/{show r.totalOutcomeCount} |
{show (round (rate * 100) :: Int)}% |
{maybe "-" show r.meanOutcomeValue} |
|]